设置mime_types在Symfony中不适用于zip文件 [英] Set mime_types not working for zip file in Symfony
本文介绍了设置mime_types在Symfony中不适用于zip文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Symfony应用程序中,我想在文件上传期间将zip文件设置为mime类型之一,执行此操作的代码如下:
In my Symfony application, I want to set zip file as one of the mime type during the file upload, the code to do this is below:
$this->validatorSchema ['Documents'] = new sfValidatorFile (
array ('mime_types' => array(
'application/zip',
'image/jpeg',
'image/pjpeg',
'image/png',
'image/x-png',
'image/gif',
'application/x-zip',
'application/octet-stream',
'application/pdf') ),
array ('invalid' => 'Invalid file.',
'required' => 'Select a file to upload.',
'mime_types' => 'The file must be of JPEG, PNG , GIF, pdf and zip format.' ) );
但是,当我进行上传时,发现所有pdf
,png
,gif
等都可以上传.唯一无法上传的MIME类型是.zip
结尾的文件.
However, when I did the uploads, I found that all of pdf
, png
, gif
etc can be uploaded. The only mime type that cannot be uploaded, are files that end with .zip
.
这是怎么回事?
我在此处问了一个相关但又不同的问题.
I asked a related, but different question here.
注意:我正在使用Symfony 1.2.7
我使用其他浏览器做了进一步的测试. Firefox 3可以使用应用程序/八位字节流"来工作,而IE可以使用应用程序/x-zip压缩"来工作,而Google Chrome浏览器根本无法工作.
推荐答案
这是一个错误 Symfony.
After more testing, I believe that this is a bug in Symfony.
这篇关于设置mime_types在Symfony中不适用于zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文