Return to Snippet

Revision: 55396
at February 5, 2012 05:44 by pruntrut


Initial Code
$config['upload_path'] = ‘./upload/banner/’;
$config['allowed_types'] = ‘jpg’;
$config['max_size'] = ’200000′;
$config['max_width'] = ’1524′;
$config['max_height'] = ’1000′;

$this->load->library(‘upload’, $config);
$this->load->library(‘image_lib’);
if ( ! $this->upload->do_upload())
{
$data = array(‘error’ => $this->upload->display_errors());
$data['product_brand']= $this->admin_ads_model->mng_brand();
$this->load->view(‘admin_view/add_product_pack’, $error);
}
else
{
$data1 = array(‘upload_data’ => $this->upload->data());
$image= $data1['upload_data']['file_name'];

$configBig = array();
$configBig['image_library'] = ‘gd2′;
$configBig['source_image'] = ‘./upload/banner/’.$image;
$configBig['create_thumb'] = TRUE;
$configBig['maintain_ratio'] = FALSE;
$configBig['width'] = 200;
$configBig['height'] = 200;
$configBig['thumb_marker'] = “_big”;
$this->image_lib->initialize($configBig);
$this->image_lib->resize();
$this->image_lib->clear();
unset($configBig);

$configBig = array();
$configBig['image_library'] = ‘gd2′;
$configBig['source_image'] = ‘./upload/banner/’.$image;
$configBig['create_thumb'] = TRUE;
$configBig['maintain_ratio'] = FALSE;
$configBig['width'] = 100;
$configBig['height'] = 100;
$configBig['thumb_marker'] = “_thumb”;
$this->image_lib->initialize($configBig);
$this->image_lib->resize();
$this->image_lib->clear();
unset($configBig);

$filename1 = $data1['upload_data']['raw_name'].’_big’.$data1['upload_data']['file_ext'];
$filename2 = $data1['upload_data']['raw_name'].’_thumb’.$data1['upload_data']['file_ext'];

rename(‘./upload/banner/’ .$filename1, ‘./upload/banner/’ .$rename);
rename(‘./upload/banner/’ .$filename2, ‘./upload/banner/’ .$rename_thumb);
unlink(‘./upload/banner/’.$image);

}

Initial URL

                                

Initial Description

                                

Initial Title
Upload -> resize multiple 

Initial Tags
php, codeigniter

Initial Language
PHP