我認爲,上傳圖片和我喜歡的輸入類型的文件:CI中上傳圖片不能正常工作
<input type="file" name="ev_pic" size="20" />
和我的控制器,如:
if(strlen($_FILES['ev_pic']['name']) > 0)
{
$pic = $this->do_upload('ev_pic');
}
做上傳方法:
public function do_upload($field) {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload($field)) {
$error = array('error' => $this->upload->display_errors());
return $error;
} else {
/*$data = array('upload_data' => $this->upload->data());
return $data;*/
$updata =$this->upload->data();
$data = $updata['raw_name'].$updata['file_ext'];
return $data;
}
}
在調試中顯示給我這個錯誤:
Severity: Notice
Message: Undefined index: ev_pic
Filename: administrator/events.php
Line Number: 68
Error Number: 1054
Unknown column 'Array' in 'field list'
UPDATE `events` SET `ev_id` = 0, `ev_text` = 0, `ev_pic` = Array
Filename: D:\AppServ\www\d5n\rashaqa2\system\database\DB_driver.php
Line Number: 330
所以我會通過ev_pic
命名文件,問題在哪裏?
安置自己不上傳的方法 –
可能重複 - (http://stackoverflow.com/questions/12769982/ [參考這個錯誤是什麼在PHP中呢?]參考這是什麼,這是錯誤的意思,在PHP) – hakre
@userNOID我會編輯我的帖子 –