Codeigniter - CSV file upload fails due to mime_type "text/x-Algol68"

Viewed 252

Trying to upload a CSV file. Some of the files fail to get uploaded. Upon deep debugging, I found a few files with mime_type "text/plain" are good to go, but with mime_type "text/x-Algol68" do not upload.

    $config['upload_path'] = './uploads/'; 
    $config['allowed_types'] = 'csv|xls|xlsx'; 
    $config['max_size'] = '100000'; 
    $config['file_name'] = 'new_'.date('d-M-Y_H:i:s').'_' . substr(md5(time()), 0, 16);

Into the System/libraries/upload.php file, I've enabled line 906 to check the mime_type of file.

        $this->_file_mime_type($_file);
         var_dump($this->file_type);exit; 

Result : string(14) "text/x-Algol68"

Also I've added mime_type in mime.php inside config directory.


return array( 
    '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','text/x-Algol68'),

Update: I've found that, in the string, there is "REF " which creates a problem. We can use str_replace method but it gets terminated before file reading, perhaps this changes the mime_type while having "REF " in the file already.

The string in CSV file is : Ref: UFOC0KE056, Remitter Info: SA SABB 068 010875 001 MUDEY MENKHR, Sender: BBMEAEADXXX,Pay Dtls: REF AES1SRMYDC INVESTMENT PURPOSE, Ord Inst: Bank

The problem is REF near AES1SRMYDC in the string.

Question: How to allow this mime_type "text/x-Algol68", either in Codeigniter or on the server?

0 Answers
Related