gpt4 book ai didi

php - 代码点火器错误: The filetype you are attempting to upload is not allowed

转载 作者:行者123 更新时间:2023-12-01 21:54:02 25 4
gpt4 key购买 nike

如果我上传 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com