【发布时间】:2013-02-13 21:09:05
【问题描述】:
我正在使用以下功能将我的图像文件上传到我的服务器(本地主机)。很好,正在上传图片。但是我需要两个图像字段,因此一旦单击提交按钮,两个图像都应该上传。我使用了此处描述的功能 Codeigniter multiple file upload ,但它不起作用。
我收到此错误消息
A PHP Error was encountered
Severity: Warning
Message: is_uploaded_file() expects parameter 1 to be string, array given
Filename: libraries/Upload.php
Line Number: 161
嗯,我不明白错误在哪里。 我用来上传单张图片的功能是
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'jpeg|png|gif';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
//failed display the errors
}
else
{
//success
}
}
此外,我还想问一下我可以更改我选择的输入字段名称吗?即我总是需要实现 <input type="file" name="userfile"/> 。是否可以更改名称?我尝试更改它并收到消息未选择文件,所以这一定意味着我无法更改它。
【问题讨论】:
标签: php html codeigniter file-upload