0
我想在CodeIgniter中使用多個文件上傳,但出現錯誤: You did not select a file to upload
。在Codeigniter中上傳多個文件時出錯
我的html代碼:
<input type="file" id="ModelImage" name="ModelImage[]" multiple="multiple" value=""/>
我的PHP代碼:
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();
}
}
}
感謝您的重播。 @jordan Arsenault – 2012-02-16 08:50:08