在我看来,输入元素看起来像这样
<input type="file" name="file[]" id="file_1" />
<input type="file" name="file[]" id="file_2" />
<input type="file" name="file[]" id="file_3" />
<input type="file" name="file[]" id="file_4" />
<input type="file" name="file[]" id="file_5" />
<input type="file" name="file[]" id="file_6" />
请帮忙我如何编写控制器来上传这些文件.. google了很多..在此先感谢
解决方法:
$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', $config);
foreach ($_FILES as $key => $value) {
if (!empty($value['tmp_name']) && $value['size'] > 0) {
if (!$this->upload->do_upload($key)) {
$errors = $this->upload->display_errors();
flashMsg($errors);
} else {
// Code After Files Upload Success GOES HERE
}
}
}
并尝试使用这样的HTML:
<input type="file" name="file1" id="file_1" />
<input type="file" name="file2" id="file_2" />
<input type="file" name="file3" id="file_3" />