SWFUpload and CI cannot correctly upload the MIME type solution to identify the MIME file

  • 2020-05-05 11:00:30
  • OfStack

The solution is as follows, and the other frameworks are similar.

Source code (/system/libraries/ upload.php 199 line)

$this- > file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']);

Change it to the following:

 
//Edit By Tacker 
if(function_exists('mime_content_type')){ 
$this->file_type = preg_replace("/^(.+?);.*$/", "\\1", mime_content_type($this->file_temp)); 
}else{ 
$this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']); 
} 

Related articles: