为允许类型创建的设置:
$config['allowed_types'] = 'doc|docx|pdf|xls|xlsx|rtf|txt|rar|zip';在我的mine.php里
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed','application/force-download'),
'rar' => array('application/x-rar', 'application/rar','application/x-rar-compressed','application/force-download'),这是我所配置的全部内容,但是当我完成zip或rar上传时,它显示的错误是“不允许您试图上传的文件类型”。
请帮助任何人..。提前谢谢..。
发布于 2013-11-30 12:51:42
我已经将zip和rar的mime.php配置替换为:
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed','application/force-download','application/octet-stream'),
'rar' => array('application/x-rar', 'application/rar','application/x-rar-compressed','application/force-download','application/octet-stream'),我刚在最后添加了application/octet-stream。这两种类型,现在我可以上传两个压缩和rar..。)现在我很高兴
发布于 2014-04-23 08:06:22
这里是检查MIME类型的最佳方法。
在代码点火器框架中开放system/libraries/upad.php。请查看下面的注释。您将得到确切的MIME类型,并在mimes.php文件中包含相同的MIME类型。
// Set the uploaded data as class variables
$this->file_temp = $_FILES[$field]['tmp_name'];
$this->file_size = $_FILES[$field]['size'];
$this->_file_mime_type($_FILES[$field]);
$this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $this->file_type);
$this->file_type = strtolower(trim(stripslashes($this->file_type), '"'));
$this->file_name = $this->_prep_filename($_FILES[$field]['name']);
$this->file_ext = $this->get_extension($this->file_name);
$this->client_name = $this->file_name;
//var_dump($this->file_type); Added by pratikn to check mime type
//exit();
// Is the file type allowed to be uploaded?
if (!$this->is_allowed_filetype()) {
$this->set_error('upload_invalid_filetype');
return FALSE;
}https://stackoverflow.com/questions/20300354
复制相似问题