Codeigniter错误:不允许您尝试上传的文件类型

If I upload a csv file, there is no problem on localhost and everything works fine, but when I upload my app on live server and upload a csv file then this error thrown: The filetype you are attempting to upload is not allowed. I am confused as to why this happens. Please help me to solve this.

For my localhost environment, I am using XAMPP and CodeIgniter.

I only want to allow csv file uploads.

check 2 things:

First: in your upload controller: make sure to set the correct allowed types

$config['allowed_types'] = 'csv';
$this->load->library('upload', $config);

Second: update the array $mimes in your config/mimes.php:

'csv'   =>  array('application/vnd.ms-excel', 
           'text/anytext', 
           'text/plain', 
           'text/x-comma-separated-values', 
           'text/comma-separated-values', 
           'application/octet-stream', 
           'application/vnd.ms-excel', 
           'application/x-csv', 
           'text/x-csv', 
           'text/csv', 
           'application/csv', 
           'application/excel', 
           'application/vnd.msexcel')

UPDATE:

you could use print_r($_FILES) in your upload controller to check for the mime-type missing. this would output something like:

[userfile] => Array
    (
        [name] => teste1.csv
        [type] => application/vnd.ms-excel
        [tmp_name] => C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\binaries\tmp\php8BFD.tmp
        [error] => 0
        [size] => 7880
    )

Add ‘text/plain’ to the CSV array in config/mimes.php to $mimes arrays, that is

'csv'   =>  array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),