php - Codeigniter - Facing issue with multiple thumbnail creation -


i playing codeigniter image upload library , uploading multiple image @ once , uploading original images thumbs.

now if upload 3 images, upload 3 original images folder: project-images. , thumbnail image goes thumbs folder. getting 1 image in thumbs folder. 2 not uploading inside thumbs folder.

what's wrong current code.

any idea?

if(!empty($_files['userfile'])){     $name_array = array();     $count = count($_files['userfile']['size']);     foreach($_files $key => $value)         ($s=0; $s<=$count-1; $s++)         {             // original image upload - start             $_files['userfile']['name'] = $value['name'][$s];             $_files['userfile']['type'] = $value['type'][$s];             $_files['userfile']['tmp_name'] = $value['tmp_name'][$s];             $_files['userfile']['error'] = $value['error'][$s];             $_files['userfile']['size'] = $value['size'][$s];             $config['upload_path'] = './public/images/project-images/';             $config['allowed_types'] = 'gif|jpg|jpeg|png|gif|jpg|jpeg|png';             $config['max_size'] = '10000';             $ci->load->library('upload', $config);             $ci->upload->do_upload();             $data = $ci->upload->data();             $name_array[] = $data['file_name'];             // original image upload - end              // thumbnail image upload - start             $config2['image_library'] = 'gd2';             $config2['source_image'] = $ci->upload->upload_path.$ci->upload->file_name;             $config2['new_image'] = './public/images/project-images/thumbs';             $config2['maintain_ratio'] = true;             $config2['create_thumb'] = true;             $config2['thumb_marker'] = '_thumb';             $config2['width'] = 370;             $config2['height'] = 200;             $ci->load->library('image_lib',$config2);              if(!$ci->image_lib->resize()){                 $ci->session->set_flashdata('errors', $ci->image_lib->display_errors('', ''));             }              // [ main image ]             $config['image_library'] = 'gd2';             $config['source_image'] = $ci->upload->upload_path.$ci->upload->file_name;             $config['maintain_ratio'] = true;             $ci->load->library('image_lib',$config);             // thumbnail image upload - end         }     return $name_array; } 

finally got solution adding code before $ci->image_lib->resize():

$ci->image_lib->clear(); $ci->image_lib->initialize($config2); 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -