I am trying to use multiple file upload in CodeIgniter, but I'm getting an error:
You did not select a file to upload
.
My html code:
<input type="file" id="ModelImage" name="ModelImage[]" multiple="multiple" value=""/>
My php code:
for($i = 0; $i < count($_FILES['ModelImage']["name"]); $i++)
{
if (!empty($_FILES['ModelImage']['name'][$i]))
{
$config['upload_path'] = './uploads/starmodel/';
$config['allowed_types'] = 'gif|jpg|png';
$config['file_name']= "star_".$lastid."_".$i.strrchr(basename($_FILES["ModelImage"]["name"][$i]),".");
$this->upload->initialize($config);
if ($this->upload->do_upload('ModelImage'))
{
$data = $this->upload->data();
$udata = array('ModelImage' => $config['file_name']);
$this->db->where('ModelID', $lastid);
$this->db->update('starmodel', $udata);
}
else
{
echo $this->upload->display_errors();
}
}
}