【发布时间】:2016-11-12 13:36:30
【问题描述】:
大家晚上好,我的代码有问题。我正在做一个带有单独字段的画廊表单。
我总是以“无”输出结束,因为即使我在 thumbnails[] 字段中输入了一些内容,它也没有得到我的输入。
任何人都知道我该如何解决它以及如何完成它。非常感谢。
这是我的 html 代码:
Main Image:
<input type="file" name="file1" required/>
Thumbnails:
<input type="file" name="thumbnails[]" />
<input type="file" name="thumbnails[]" />
<input type="file" name="thumbnails[]" />
在我的控制器中:
$config = array(
'upload_path' => "./uploads/workplace/",
'allowed_types' => "jpg|png|jpeg",
'remove_spaces' => TRUE,
'max_size' => "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb)
'max_height' => "0",
'max_width' => "0"
);
$this->load->library('upload', $config);
if($this->upload->do_upload('file1'))
{
$config = array(
'upload_path' => "./uploads/workplace/",
'allowed_types' => "jpg|png|jpeg",
'remove_spaces' => TRUE,
'max_size' => "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb)
'max_height' => "0",
'max_width' => "0"
);
$this->load->library('upload', $config);
if($this->upload->do_upload('thumbnails[]'))
{
echo "yea";
}
else
{
echo "none";
}
}
【问题讨论】:
标签: php codeigniter file-upload