Upload and resize


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function do_upload() {
  2.  
  3. $config = array(
  4. 'allowed_types' => 'jpg|jpeg|gif|png',
  5. 'upload_path' => $this->gallery_path,
  6. 'max_size' => 2000
  7. );
  8.  
  9. $this->load->library('upload', $config);
  10. $this->upload->do_upload();
  11. $image_data = $this->upload->data();
  12.  
  13. $config = array(
  14. 'source_image' => $image_data['full_path'],
  15. 'new_image' => $this->gallery_path . '/thumbs',
  16. 'maintain_ration' => true,
  17. 'width' => 180,
  18. 'height' => 150
  19. );
  20.  
  21. $this->load->library('image_lib', $config);
  22. $this->image_lib->resize();
  23.  
  24. }
  25.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.