尝试在Codeigniter中上传XML文件时。我正在使用eFax,试图设置入站传真传递:启用XML发布。每当我使用他们提供的Sample.xml文件进行测试时,我都会收到以下错误:
The filetype you are attempting to upload is not allowed.
其他文件将上传罚款。在我的上传配置中,xml
设置在allowed_types
:的选项中
$config['allowed_types'] = 'txt|xml';
为什么Codeigniter不允许使用eFax XML文档类型?
我已经弄清楚了发生这种情况的原因。默认情况下,MIME类型未在Codeigniter的mimes.php
配置文件中设置。我需要为xml
MIME添加一个多个MIME类型的数组。具体来说,我需要添加application/xml
。
所以在/application/config/mimes.php
中,我更改了这一行:
'xml' => 'text/xml',
对此(将xml
选项转换为数组):
'xml' => array('text/xml', 'application/xml'),
这立刻解决了问题。
这就是我使用的
'xml' => array('application/xml', 'text/xml', 'text/plain'),
注意:将其粘贴到/application/config/mimes.php