代码点火器文件上传不允许


CodeIgniter FileUpload Not Allowed

我正在CodeIgniter中设置上传表单。我已将allowed_types参数设置为:

  $config['allowed_types'] = 'xls|xlsx';

并在 config/mimes.php 中添加了以下行:

'xls'   =>  array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
'xlsx'  =>  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',

但是,尽管我尝试上传的文件是 xlsx 文件 CI 仍然告诉我不允许使用文件类型。有什么想法吗?

  public function do_upload() {
    // Change this if you change the upload directory
    $upload_path = "/webusers/ad6vcf/public_html/funding_manager/application/uploads";
    $config['upload_path'] = $upload_path;
    //At some point will add support for csv
    $config['allowed_types'] = 'xls|xlsx';
    //Max 5000kb please
    $config['max_size'] = '5000';
    $this->load->library('upload', $config);
    $this->upload->initialize($config);

    if (!$this->upload->do_upload())
    {
        $error = array('error' => $this->upload->display_errors());
        $this->upload($error);
    } else {
        $upload_data = $this->upload->data();
        bulk_insert($upload_path . $upload_data['file_name']);
    }
}

请尝试这个

$this->load->library('upload', $config); $this->upload->initialize($config);

你试过这个吗?

if (!$this->upload->do_upload('put the name of the input field here'))