我经常搜索并发现很多关于这个问题的问题,遗憾的是没有一个答案对我有帮助.
我正在尝试上传png图像,我收到以下错误:
The filetype you are attempting to upload is not allowed.
这是我得到的:
查看文件:
[..]
= form_open_multipart() ?>
= form_close() ?>
[..]
我的控制器:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$xx = array('upload_data' => $this->upload->data());
$mimetype= $xx['upload_data']['file_type'];
var_dump('Mime: ' . $mimetype);
var_dump($_FILES);
if ( !$this->upload->do_upload())
{
Notice::add($this->upload->display_errors(), 'error');
}
else
{
$data['upload_data'] = $this->upload->data();
}
正如你所看到的,我正在尝试var_dump mime类型,结果为空.
当我做var_dump($_ FILES)时,看起来一切都很好:
array(1) { ["userfile"]=> array(5) { ["name"]=> string(14) "imageofm.png" ["type"]=> string(9) "image/png" ["tmp_name"]=> string(18) "/var/tmp/php5cDAZJ" ["error"]=> int(0) ["size"]=> int(358) } }
另外,我得到’png’=>数组(‘image / png’,’image / x-png’),line,在我的config / mimes.php中.
但是,它确实发生在所有图像上(还没有尝试过其他扩展).
我很感激每一次尝试.