CodeIgniter的文件上传库忽略allowed_types? [英] CodeIgniter's file upload library ignores allowed_types?

查看:283
本文介绍了CodeIgniter的文件上传库忽略allowed_types?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试上传证书文件并失败:

I tried to upload a certificate file and failed:

$config["allowed_types"] = "cer";
$this->load->library("upload", $config);
$this->upload->do_upload("fieldname");

我总是得到以下错误,即使我上传一个.cer文件:

I always get the following error, even if I upload a .cer file:

The filetype you are attempting to upload is not allowed

这是一个谎言,我上传了一个允许类型的文件!
为什么此类忽略其记录设置allowed_types?

That is a lie, I uploaded a file of an allowed type! Why does this class ignore its documented setting allowed_types?

推荐答案

您需要在 mimes.php 配置文件中添加mime类型。应该是这样:

You need to add the mime type in mimes.php config file. It should be something like this:

'cer' => array('application/x-x509-ca-cert', 'application/octet-stream'),

这篇关于CodeIgniter的文件上传库忽略allowed_types?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆