作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果我上传 csv
文件,localhost
上没有问题,一切正常,但是当我在实时服务器上上传我的应用程序并上传 csv
文件,然后抛出此错误:不允许您尝试上传的文件类型。
我很困惑为什么会发生这种情况。请帮我解决这个问题。
对于我的 localhost
环境,我使用 XAMPP 和 CodeIgniter。
我只想允许 csv
文件上传。
最佳答案
检查两件事:
第一:在您的上传 Controller 中:确保设置正确的允许类型
$config['allowed_types'] = 'csv';
$this->load->library('upload', $config);
第二:更新 config/mimes.php 中的数组 $mimes
:
'csv' => array('application/vnd.ms-excel',
'text/anytext',
'text/plain',
'text/x-comma-separated-values',
'text/comma-separated-values',
'application/octet-stream',
'application/vnd.ms-excel',
'application/x-csv',
'text/x-csv',
'text/csv',
'application/csv',
'application/excel',
'application/vnd.msexcel')
更新:
您可以在上传 Controller 中使用 print_r($_FILES)
来检查是否缺少 mime 类型。这会输出类似:
[userfile] => Array
(
[name] => teste1.csv
[type] => application/vnd.ms-excel
[tmp_name] => C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\binaries\tmp\php8BFD.tmp
[error] => 0
[size] => 7880
)
关于php - 代码点火器错误: The filetype you are attempting to upload is not allowed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29167444/
我是一名优秀的程序员,十分优秀!