i am trying to do multiple image upload with different file input with the following code
<input name="attachement[]" type="file">
<input name="attachement[]" type="file">
My codeigniter code is
$config = array(
'upload_path' => $path,
'max_size' => 1024 * 100,
'allowed_types' => 'gif|jpeg|jpg|png',
'overwrite' => true,
'remove_spaces' => true);
$images = array();
$this->load->library('upload');
$files = $_FILES;
$count = count($_FILES[$attachName]['name']);
for ($i = 0; $i < $count; $i++) {
$_FILES[$attachName]['name'] = $files[$attachName]['name'][$i];
$_FILES[$attachName]['type'] = $files[$attachName]['type'][$i];
$_FILES[$attachName]['tmp_name'] = $files[$attachName]['tmp_name'][$i];
$_FILES[$attachName]['error'] = $files[$attachName]['error'][$i];
$_FILES[$attachName]['size'] = $files[$attachName]['size'][$i];
$fileName = $title . '_' . $_FILES[$attachName]['name'];
$images[] = $fileName;
$config['file_name'] = $fileName;
$this->upload->initialize($config);
$this->upload->do_upload();
if ($this->upload->do_upload()) {
$return['data'][] = $this->upload->data();
$return['status'] = "success";
$return['msg'] = sprintf($this->lang->line('success_item_added'), "Image", "uploaded");
} else {
$return['status'] = 'danger';
$return['msg'] .= $this->upload->display_errors('', '') . "\r";
}
}
In the code above $attachName="attachement"
But i get error You did not select any file to upload
what am i doing wrong?