php - Codeigniter 3 upload not saving thumb to directory -
i trying save thumbnail image directory, not working. able save original image , save info database, reason thumbnail not saving thumbs directory create. directory has read/write access. note using dropzone.js.
here partial code:
if ( ! $this->upload->do_upload('file')) { //upload failed, echo negative response dropzone.js } else { //upload success, upload file(s) $image_data = $this->upload->data(); $img_config['source_image'] = '/uploads/videos/'.$image_data['file_name']; $img_config['new_image'] = '/uploads/videos/thumbs/'.$image_data['file_name']; $img_config['create_thumb'] = true; $img_config['maintain_ratio'] = true; $img_config['width'] = 251; $img_config['height'] = 180; $this->load->library('image_lib', $img_config); $this->image_lib->resize(); $file = array( 'user_id' => $this->my_auth->logged_in(), 'img_name' => $image_data['raw_name'], 'thumb_name' => $image_data['raw_name'].'_thumb', 'ext' => $image_data['file_ext'], 'upload_date' => time() ); $this->upload_model->add_image($file); $data['img_success'] = '<div class="alert alert-success" id="imgsuccess">your image <strong>' . $image_data['file_name'] . '</strong> uploaded!</div>'; $this->load->view('templates/frontend/front_header', $data); $this->load->view('templates/frontend/front_navbar'); $this->load->view('frontend/upload_images', $data); $this->load->view('templates/frontend/front_footer', $data); }
i able save original image, not thumbnail. can see wrong here?
i added __construct
:
$this->original_path = realpath(apppath.'../uploads/images'); $this->thumbs_path = realpath(apppath.'../uploads/images/thumbs');
and changed source_image
, new_image
configs:
$img_config['source_image'] = $image_data['full_path']; $img_config['new_image'] = $this->thumbs_path;
this seems have fixed it.
Comments
Post a Comment