【发布时间】:2012-02-28 04:36:49
【问题描述】:
我的问题是为什么我的代码无法将 .png 文件存储在数据库中并上传文件夹,但除了 .jpg、.gif 等文件我成功插入数据库并上传文件夹之外,我还包含 $config['allowed_types'] = 'png',另外,这是我 var_dump 输出的错误消息“不允许您尝试上传的文件类型。” , 知道如何解决我的问题吗?
这是我的代码:
$upload_file_name = '';
$config['upload_path'] = '/var/www/html/uploads/';
$config['allowed_types'] = 'jpg|gif|png';
$config['max_size'] = 100000;
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
if(!$this->upload->do_upload('receipt_attachment'))
{
$error = array('error' => $this->upload->display_errors());
$errormessage = $this->upload->display_errors();
$this->session->set_flashdata('error', $errormessage);
redirect('home/add_product');
}else{
$upload_data = $this->upload->data();
$upload_file_name = $upload_data['file_name'];
}
谢谢
【问题讨论】:
-
可能是您的文件扩展名是大写PNG,这有时也可能导致问题...!
标签: php codeigniter