Im doing multiple file uploading, which is working fine. im getting both images but the other image which is thumnail not getting their given path and also not changing in to thumb size.
I have just issues with thumbnail in "thumbnail creation start" area i hope. check my array and let me know my mistake.
controller codes
public function addimage($room_id)
{
$name_array = array();
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key=>$value)
for($s=0; $s<=$count-1; $s++)
{
$_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'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
$this->upload->do_upload();
$data = $this->upload->data();
$name_array[] = $data['file_name']; // get file names for first file
//thumbnail creation start
$config1['image_library'] = 'gd2';
$config1['source_image'] = $image['full_path'];
$config1['create_thumb'] = TRUE;
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config1['maintain_ratio'] = TRUE;
$config1['upload_path'] = './uploads/thumbs/';
$config1['width'] = 150;
$config1['height'] = 150;
$this->load->library('image_lib', $config1);
$this->image_lib->resize();
$this->upload->do_upload();
$data = $this->upload->data();
$name_array1[] = $data['file_name']; // file names for thumb
//thumbnail creation end
}
$names= implode(',', $name_array);
$names2= implode(',', $name_array1);
//print_r($names);
$options = array(
'id' => '0',
'org_image' => $names,
'thumbnail' => $names2,
'room_id' => $room_id,
'created' => '1',
'status' => '1'
);
$this->rooms_model->room_images_insert($options);
redirect('/admin/rooms', 'location');
} //end of function
Replace
To
Also remove the following commented lines