Codeigniter xml file not uploading

家住魔仙堡 提交于 2020-06-13 04:59:09

问题


When trying to upload an XML file in Codeigniter. I am working with eFax, trying to set up Inbound Fax Delivery: Enabling XML Posting. I am getting the following error anytime I do a test post using their Sample.xml file they have provided:

The filetype you are attempting to upload is not allowed.

Other documents will upload fine. In my upload config, xml is set in the options for allowed_types:

$config['allowed_types'] = 'txt|xml';

Why does Codeigniter not allow the eFax XML document type?


回答1:


I've figured out why this was happening. By default, the MIME type was not set in Codeigniter's mimes.php config file. I needed to add an array of multiple MIME types for the xml MIME. Specifically, I needed to add application/xml.

So in /application/config/mimes.php I changed this line:

'xml' => 'text/xml',

To this (converting the xml option to an array):

'xml' => array('text/xml', 'application/xml'),

That fixed the problem right away.




回答2:


this is the one I use:

'xml'   =>  array('application/xml', 'text/xml', 'text/plain'),

NOTE: paste it in /application/config/mimes.php



来源:https://stackoverflow.com/questions/18366558/codeigniter-xml-file-not-uploading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!