【问题标题】:File upload in codeigniter in IE: The filetype you are attempting to upload is not allowedIE中codeigniter中的文件上传:不允许您尝试上传的文件类型
【发布时间】:2023-04-07 22:08:01
【问题描述】:

我正在使用 codeigniter 和 jQuery 表单插件。

我正在尝试上传一个文件,但它无法与 IE 一起使用。

请检查我的控制器:

    if($fileCount >0)

    {

    //there are some files



    //configure upload


    $config['upload_path'] = 'crm_data/crm_customer_data';

    $config['allowed_types'] = 'zip|rar|doc|pdf|gif|jpg|jpeg|docx';

    $config["max_size"] = 2048;

    $config['encrypt_name'] = true;


    //loading upload

    $this->load->library("upload");

    $this->upload->initialize($config);

if($this->upload->do_upload("attach"))

        {

        $l = $this->upload->data();

        $logs["attachment"] =  $l["file_name"];


        }

    else

    {

    //some errors on upload                             exit(json_encode(array("status"=>FALSE,"reason"=>$this->upload->display_errors())));

    }

这里是html

<input type="file" id="attach" name="attach" />

它在除 IE 之外的其他浏览器中运行良好。

查看回复。

var_dump($_FILES)


array
  'attach' => 
    array
      'name' => string 'invoice_record_and_list.zip' (length=31)
      'type' => string '' (length=0)
      'tmp_name' => string 'C:\wamp\tmp\phpF467.tmp' (length=23)
      'error' => int 0
      'size' => int 1467474

在 IE 中我收到以下错误。

您尝试上传的文件类型不允许。

编辑:

我注意到 IE 上的一些 var_dump 给了我一个 "" for type但在 FF 我得到了'type' =&gt; string 'application/x-zip-compressed' (length=28)

【问题讨论】:

    标签: php codeigniter internet-explorer file-upload


    【解决方案1】:

    这可能会有所帮助。

    IE 未发送您的“zip”的 mime 类型(例如:'type' =&gt; string)。 所以只需在您的 config/memi.ph 中附加一个带有类似文件类型的空值。

    'zip' =&gt; array('application/x-zip', 'application/zip', 'application/x-zip-compressed',"")

    【讨论】:

      猜你喜欢
      • 2011-11-21
      • 2017-08-18
      • 2012-04-06
      • 2014-12-30
      • 2011-06-08
      • 2012-04-22
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      相关资源
      最近更新 更多