我正在使用下面的函數將我的圖像文件上傳到我的服務器(Localhost)。這是好的,圖像正在上傳。但是我需要兩個圖像域,因此一旦點擊提交按鈕,圖像就應該被上傳。我用這裏描述的功能Codeigniter multiple file upload,但它不工作。在codeigniter中上傳圖像,是否需要userfile?
我收到此錯誤信息
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"/>
。是否可以更改名稱?我試着改變它,我收到消息沒有選擇文件,所以這意味着我不能改變它。
我仍然收到我在問題中發佈的錯誤消息。 – prakashchhetri 2013-02-13 21:22:38
修正了一個錯誤。 – 2013-02-13 21:28:18
它只上傳一張圖片 – prakashchhetri 2013-02-13 22:04:58