Posted By

pruntrut on 02/05/12


Tagged

php codeigniter


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Kurt


Upload -> resize multiple


 / Published in: PHP
 

  1. $config['upload_path'] =./upload/banner/’;
  2. $config['allowed_types'] = ‘jpg’;
  3. $config['max_size'] =200000′;
  4. $config['max_width'] =1524′;
  5. $config['max_height'] =1000′;
  6.  
  7. $this->load->library(‘upload’, $config);
  8. $this->load->library(‘image_lib’);
  9. if ( ! $this->upload->do_upload())
  10. {
  11. $data = array(‘error’ => $this->upload->display_errors());
  12. $data['product_brand']= $this->admin_ads_model->mng_brand();
  13. $this->load->view(‘admin_view/add_product_pack’, $error);
  14. }
  15. else
  16. {
  17. $data1 = array(‘upload_data’ => $this->upload->data());
  18. $image= $data1['upload_data']['file_name'];
  19.  
  20. $configBig = array();
  21. $configBig['image_library'] = ‘gd2′;
  22. $configBig['source_image'] =./upload/banner/.$image;
  23. $configBig['create_thumb'] = TRUE;
  24. $configBig['maintain_ratio'] = FALSE;
  25. $configBig['width'] = 200;
  26. $configBig['height'] = 200;
  27. $configBig['thumb_marker'] = “_big”;
  28. $this->image_lib->initialize($configBig);
  29. $this->image_lib->resize();
  30. $this->image_lib->clear();
  31. unset($configBig);
  32.  
  33. $configBig = array();
  34. $configBig['image_library'] = ‘gd2′;
  35. $configBig['source_image'] =./upload/banner/.$image;
  36. $configBig['create_thumb'] = TRUE;
  37. $configBig['maintain_ratio'] = FALSE;
  38. $configBig['width'] = 100;
  39. $configBig['height'] = 100;
  40. $configBig['thumb_marker'] = “_thumb”;
  41. $this->image_lib->initialize($configBig);
  42. $this->image_lib->resize();
  43. $this->image_lib->clear();
  44. unset($configBig);
  45.  
  46. $filename1 = $data1['upload_data']['raw_name'].’_big’.$data1['upload_data']['file_ext'];
  47. $filename2 = $data1['upload_data']['raw_name'].’_thumb’.$data1['upload_data']['file_ext'];
  48.  
  49. rename(./upload/banner/.$filename1,./upload/banner/.$rename);
  50. rename(./upload/banner/.$filename2,./upload/banner/.$rename_thumb);
  51. unlink(./upload/banner/.$image);
  52.  
  53. }

Report this snippet  

You need to login to post a comment.