目前有這些代碼。圖片上傳數據爲空
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '270';
$config['max_height'] = '280';
$this->load->library('upload', $config);
然後生病插入細節到數據庫中。
$this->Model->upload_image($this->upload->data(),$result_id);
但是db行是空的,所以我檢查了自己。 I print_r($image_data)
這是模型函數的第一個參數。仍然是空的,以確保即使mor。我輸入了。
print_r($this->upload->data());
不過,結果卻是空的。
陣列([文件名] => [FILE_TYPE] => [FILE_PATH] => ./uploads/ [full_path] => ./uploads/ [RAW_NAME] => [orig_name] => [CLIENT_NAME] => [file_ext] => [FILE_SIZE] => [is_image] => [IMAGE_WIDTH] => [IMAGE_HEIGHT] => [IMAGE_TYPE] => [image_size_str] =>)
編輯:
if (! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('view', $error);
}
else
{
$image_data = array('upload_data' => $this->upload->data());
print_r($this->upload->data());
}
你運行過'$ this-> upload-> do_upload()'嗎? – Samutz
我添加了do_upload()代碼行,雖然它不會print_r .... 順便說一句,我是否需要命名函數do_upload呢? – user3205047
你能否在你的問題中包含具有表單的視圖? – Samutz