韦尔,我相信这不是代码签名人问题perse,因为它更像是themime-type.。 我正在尝试上传文件,XLS(或XLSX)文件和Mime-type浏览器,而PHP报告为
Application/optet-stream而不是application/excelly/excel,Application/vnd.mms-excelly或msexcelly/msexcells。当然,CodeIgniter上传插件将报告一个错误(无效的文件类型),因为它试图将文件扩展名与Mime-Type匹配。 怪异的事情可能是相同的代码工作了几个月,现在停止使用最新的Chrome(16.0.912.77),Firefox(10.0)和IE9。 是否有人有相同的(或类似)的问题,并且要分享解决方案? 谢谢你。 PS:我不会提供代码,因为这不是真正的代码,但是如果需要,我将上传一些片段。
eDit
可能是相关的:在类似配置上,同一浏览器不会发生错误,但是使用MS Office而不是Libre Office(在我的PC上)。它也不会在基于GNU/Linux的 + Libre Office系统上发生。因此,可能是Windows在开源套房上很难播放,或者是为了为之而改变的Libre Office更改哑剧类型吗?
我也会遇到此错误。 CI正在报告“应用程序/zip”的文件类型,该文件类型是有意义的,因为XLSX格式是压缩格式(将其重命名为zip,您可以打开内容)。 I已将以下行添加到MIME类型文件(application/config/config/mimes.php):
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/zip'),
please,浏览以下描述和提示,并轻松获取答案!
描述:实际上,与许多人建议在文件中添加/替换以下行(application/config/config/mimes.php):
但是我已经意识到,在** Codeigniter版本2.2中。***问题有些不同! 他们已经添加了该行,但忘了添加以下“ file_type” ==>'application/vnd.ms-excel'
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel'),
so将上述'Application/vnd.ms-excel'
添加到xlsx
文件类型的数组中,让我上传.xlsx文件!
当您在CodeIgniter平台上遇到以下错误并上传文件时: 不允许您尝试上传的菲尼特类型。
在您的控制器的上传方法中注册以下内容,
var_dump($this->upload->data());
link
中获得一个想法。(请参阅该页面的末尾)。在该数组中,您可以获得您要上传的文件的真正mime_type,但不给您上传。 sandwer:.xlsx在我的情况下,我的文件扩展名为
,Mime类型为
application/vnd.ms-excel,未添加到
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip'),
我手动添加了它,之后它效果很好!verry !!!
当我检查文件扩展名为
时,Same偶然碰巧上传了CSV,但是当我将其添加到以下行中时,MIME类型为文本/平原:
'csv' => array('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');
保存如下,
'csv' => array('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', 'text/plain'),
几个月前,这是一个CI错误:https://github.com/ellislab/codeigniter/issues/394。框架中的mimes.php已更新,并解决了错误。将您的CodeIgniter库更新为2.1.0(或更新)。
此外,测试/转储的一件好事是您的服务器MIME类型。 其他替代方案是迫使MIME类型。使用.htaccess,那将是AddType application/excel .xls .xlsx
对于整个调试冒险,请使用文件助手(http://codeigniter.com/user_guide/helpers/helpers/file_helper.html)测试各种Office文件。
get_mime_by_extension($file)
但宁愿使用上面的解决方案,我不喜欢弄乱注册表。
这对我有用。
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\.xls]
"Content Type"="application/excel"
[HKEY_CURRENT_USER\Software\Classes\.xlsx]
"Content Type"="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"