I want to upload my images array in codeigniter. The names of images are name = standimages[]
. This is my controller
$config['upload_path'] = './uploads/individual_stands/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '1024';
$config['max_width'] = '1920';
$config['max_height'] = '1280';
$config['overwrite'] = FALSE;
echo $this->upload_images($config, $_FILES, 'standimages');
And my function
function upload_images($config, $files, $name) {
if (!file_exists($config['upload_path'])) {
mkdir($config['upload_path'], 0777, true);
}
$filesCount = count($files[$name]['name']);
for ($i = 0; $i < $filesCount; $i++) {
$files['userFile']['name'] = $files[$name]['name'][$i];
$files['userFile']['type'] = $files[$name]['type'][$i];
$files['userFile']['tmp_name'] = $files[$name]['tmp_name'][$i];
$files['userFile']['error'] = $files[$name]['error'][$i];
$files['userFile']['size'] = $files[$name]['size'][$i];
pre($files);
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ($this->upload->do_upload($files['userFile'])) {
$fileData = $this->upload->data();
$uploadData[$i]['file_name'] = $fileData['file_name'];
$uploadData[$i]['created'] = date("Y-m-d H:i:s");
$uploadData[$i]['modified'] = date("Y-m-d H:i:s");
}
}
if (!empty($uploadData)) {
//Insert file information into the database
$insert = $this->file->insert($uploadData);
return $statusMsg = $insert ? 'Files uploaded successfully.' : 'Some problem occurred, please try again.';
}
}
Any idea why my images are not being uploaded?