近日,做了一个CI网站的上传类,老是报上传文件类型错误,现在终于有了解决方法了,和大家分享一下。
源代码(/system/libraries/upload.php 199 line) 

$this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $this->file_type); 

修改成如下:
 
if(function_exists('mimes_types')){ 
$this->file_type = preg_replace("/^(.+?);.*$/", "\\1",mimes_types($this->file_temp)); 
}else{ 
$this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']); 
posted on 2016-06-04 17:32  草根落叶随风  阅读(507)  评论(0)    收藏  举报