php - Multiple images resizing toupload folder in Codeiniter -
i have controller inserts images upload folder without resizing them.
public function upload() { $this->load->library('upload'); $config['upload_path'] = fcpath . 'uploads/property-images'; $config['allowed_types'] = 'gif|jpg|png'; $config['file_name'] = 'property_image_1'; $config['max_size'] = '0'; $config['overwrite'] = false; ($i = 0; $i < $number_of_files; $i++) { $_files['uploadedimage']['name'] = $files['name'][$i]; $_files['uploadedimage']['type'] = $files['type'][$i]; $_files['uploadedimage']['tmp_name'] = $files['tmp_name'][$i]; $_files['uploadedimage']['error'] = $files['error'][$i]; $_files['uploadedimage']['size'] = $files['size'][$i]; $this->upload->initialize($config); if ($this->upload->do_upload('uploadedimage', $i)) { $data['uploadedimage'] = $this->upload->data(); $image_name[$i] = $data['uploadedimage']['file_name']; //$this->_property_images_resize($data); // private function resize $data['images'] = implode(',',$image_name); $this->model_users->insert_property_details($data)) redirect('view'); } else { $this->form_validation->set_message('fileupload_check', $this->upload->display_errors()); return false; } } } i further needed resize images of private function in controller:
private function _property_images_resize($data) { $this->load->library('image_lib'); $config = array( 'image_library' => 'gd2', 'source_image' => 'uploads/property-images/'.$data['uploadedimage']['file_name'], 'new_image' => 'uploads/profile/test1/', 'create_thumb' => true, 'maintain_ratio' => true, 'width' => 10, 'height' => 10 ); $this->image_lib->initialize($config); if(!$this->image_lib->resize()) echo $this->image_lib->display_errors(); } after adding second function, changes nothing. images uploads way before without resizing.
looking someone's can't figure out.
for validation callback
function if_image_was_selected(){ $this->form_validation->set_message('if_image_was_selected', 'please select @ least 1 image in jpg/jpeg/png/gif format.'); $number_of_files = count($_files['uploadedimages']['tmp_name']); $files = $_files['uploadedimages']; for($i=0;$i<$number_of_files;$i++) { if($_files['uploadedimages']['error'][$i] != 0) { return false; }else{ return true; } } }
are sure not suppose call:
$this->load->library('image_lib', $config); instead of
$this->image_lib->initialize($config); does webserver user have write permissions uploads/profile/test1/ directory?
do error message? have checked php log or apache log?
try adding code below, above code see error echo'd out screen if can.
error_reporting(e_all); ini_set("display_errors", 1);
Comments
Post a Comment