CodeIgniter Forums
upload library processing with wrong mime type - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: upload library processing with wrong mime type (/showthread.php?tid=73504)



upload library processing with wrong mime type - hemantmudgil - 05-01-2019

First, thanks for providing such a wonderful framework. I'm new here, don't know about many rules of the forum so sorry in advance.


I found the custom mime is not working and also, the _file_mime_type() not working correctly.

Basically if i upload any apk file then the mime should be "application/vnd.android.package-archive" but program returning only "application/zip". Maybe i'm wrong(i know that this wonderful framework is developed by the best php experts around the globe) but please help me to understand how i can deal with it.

I started debugging and landed on this function. Here is the code:

      if (function_exists('finfo_file'))
      { 
         $finfo = @finfo_open(FILEINFO_MIME);
         if (is_resource($finfo)){
            $mime = @finfo_file($finfo, $file['tmp_name']);
            finfo_close($finfo);

            if (is_string($mime) && preg_match($regexp, $mime, $matches))
            {
               log_message('error', json_encode([$mime, $matches,$matches[1]]));
               $this->file_type = $matches[1];
               return;
            }
         }
      }



RE: upload library processing with wrong mime type - InsiteFX - 05-02-2019

You would need to add that mime type to CodeIgniters mimes

./application/config/mimes.php

Just look at the others and then add your type like them.


RE: upload library processing with wrong mime type - Paradinight - 05-02-2019

(05-02-2019, 03:35 AM)InsiteFX Wrote: You would need to add that mime type to CodeIgniters mimes

./application/config/mimes.php

Just look at the others and then add your type like them.

wrong. finfo is the problem https://bugs.php.net/bug.php?id=74573


RE: upload library processing with wrong mime type - Zapata5N - 01-24-2020

Application/zip is chosen because the file in fact a zip file containing xml. Wrong mime type gives problem when opening the file from web interface.