如何在codeigniter中上传多个文件
<input type="file" name="pic[]">
<input type="file" name="pic[]">
<input type="file" name="pic[]">
如何上传?
使用do_upload函数
答案 0 :(得分:8)
您可以上传任意数量的文件
$config['upload_path'] = 'upload/Main_category_product/';
$path=$config['upload_path'];
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '1024';
$config['max_width'] = '1920';
$config['max_height'] = '1280';
$this->load->library('upload');
foreach ($_FILES as $key => $value)
{
if (!empty($key['name']))
{
$this->upload->initialize($config);
if (!$this->upload->do_upload($key))
{
$errors = $this->upload->display_errors();
flashMsg($errors);
}
else
{
// Code After Files Upload Success GOES HERE
}
}
}
您可以看到不需要名称属性。