Guest User

Untitled

a guest
Jul 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. class Upload_mod extends CI_Model{
  2.  
  3. var $gallery_path;
  4. var $gallery_path_url;
  5.  
  6. function index(){
  7. parent::__construct();
  8. $this->gallery_path = realpath(APPPATH . '../uploads');
  9. $this->gallery_path_url = base_url().'uploads/';
  10. }
  11.  
  12. function do_upload() {
  13. $config = array(
  14. 'allowed_types' => 'jpg|jpeg|gif|png',
  15. 'upload_path' => $this->gallery_path);
  16.  
  17. $this->load->library('upload');
  18. $this->upload->initialize($config);
  19. $this->upload->do_upload();
  20. $image_data = $this->upload->data();
  21. print_r($image_data);
  22.  
  23. if ( ! $this->upload->do_upload())
  24. {
  25. $error = array('error' => $this->upload->display_errors());
  26. gd_info();
  27. echo $error;
  28. }
  29.  
  30. $config['source_image'] = $image_data['full_path'];
  31. $config['new_image'] = $this->gallery_path . '/thumbs';
  32. $config['maintain_ratio'] = TRUE;
  33. $config['width'] = 75;
  34. $config['height'] = 50;
  35.  
  36. $this->load->library('image_lib');
  37. $this->image_lib->initialize($config);
  38. $this->image_lib->resize();
  39.  
  40. if ( ! $this->image_lib->resize())
  41. {
  42. echo $this->image_lib->display_errors();
  43. }
  44.  
  45. }
  46. }
  47.  
  48. $this->load->library('image_lib');
  49. $this->image_lib->initialize($config);
  50. // $this->image_lib->resize(); Remove this call to resize()
  51.  
  52. if ( ! $this->image_lib->resize())
  53. {
  54. echo $this->image_lib->display_errors();
  55. }
  56.  
  57. $this->load->library('image_lib');
  58. $this->image_lib->initialize($config);
  59. $success = $this->image_lib->resize();
  60.  
  61. if ( ! $success)
  62. {
  63. echo $this->image_lib->display_errors();
  64. }
Add Comment
Please, Sign In to add comment