【问题标题】:Codeigniter xml file not uploadingCodeigniter xml文件未上传
【发布时间】:2013-08-24 08:44:14
【问题描述】:

尝试在 Codeigniter 中上传 XML 文件时。我正在使用 eFax,尝试设置 Inbound Fax Delivery: 启用 XML Posting。每当我使用他们提供的 Sample.xml 文件进行测试发布时,我都会收到以下错误:

The filetype you are attempting to upload is not allowed.

其他文件可以正常上传。在我的上传配置中,xmlallowed_types 的选项中设置:

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

为什么 Codeigniter 不允许 eFax XML 文档类型?

【问题讨论】:

    标签: php xml codeigniter codeigniter-upload


    【解决方案1】:

    这是我使用的:

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

    注意:将其粘贴到/application/config/mimes.php

    【讨论】:

      【解决方案2】:

      我已经弄清楚为什么会发生这种情况。默认情况下,Codeigniter 的 mimes.php 配置文件中未设置 MIME 类型。我需要为xml MIME 添加多个MIME 类型的数组。具体来说,我需要添加application/xml

      所以在/application/config/mimes.php我改变了这一行:

      'xml' => 'text/xml',
      

      为此(将xml 选项转换为数组):

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

      这立即解决了问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-02-12
        • 2012-08-11
        • 2012-10-07
        • 1970-01-01
        • 2014-03-16
        • 2011-10-19
        • 2011-11-06
        相关资源
        最近更新 更多