這是我上傳的模型笨圖片上傳 - 不能得到錯誤信息顯示
function upload_avatar()
{
$id = $this->tank_auth->get_user_id();
//config upload parameters and upload image
$config = array(
'allowed_types' => 'jpeg|jpg|png',
'upload_path' => $this->upload_path,
'max_size' => 2048,
'encrypt_name' => TRUE,
'overwrite' => FALSE,
);
$this->load->library('upload', $config);
$this->upload->do_upload();
//get upload data, config, resize uploaded image, save in avatars subfolder
$image_data = $this->upload->data();
if ($image_data['file_size'] < 2048) {
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $this->upload_path . '/avatars',
'maintain_ratio' => TRUE,
'width' => 125,
'height' => 125
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
//only burn avatar path to user_profiles table if no upload errors
if (!$this->upload->display_errors()) {
$data = array('avatar' => base_url() . 'images/avatars/' . $image_data['file_name']);
$this->db->where('id', $id);
$this->db->update('user_profiles', $data);
}
//delete the original file from server
$this->load->helper('file');
unlink($image_data['full_path']);
} else {
echo $this->upload->display_errors();
}
}
我不能得到錯誤信息來呼應直到瀏覽器時,我嘗試上傳一個文件> 2MB。
公平地說,CI會忽略這個大文件,並在文件爲< 2MB時正確上傳。
唯一的問題是我無法獲得錯誤消息在前端顯示給suer一些反饋。
任何想法這裏有什麼不對?
yes''max_size'=> 2048,'限制文件小於2MB - 但是當我註釋掉那一行時,我仍然沒有得到錯誤信息 – pepe 2011-04-19 00:47:55
'post_max_size'在php.ini中定義,而不是你的腳本。 – preinheimer 2011-04-19 00:51:14
哦 - 無論如何,如果我增加''max_size''我**可以**上傳圖像> 2MB,所以我不認爲php.ini配置在任何方式,防止它 – pepe 2011-04-19 00:57:05