修复上传类型配置mimetype无效的BUG

pull/222/head
Karson 2020-08-13 16:11:13 +08:00
parent 82966e07c3
commit 285095f80f
1 changed files with 5 additions and 6 deletions

View File

@ -90,13 +90,12 @@ class Upload
$mimetypeArr = explode(',', strtolower($this->config['mimetype']));
$typeArr = explode('/', $this->fileInfo['type']);
//验证文件后缀
if ($this->config['mimetype'] !== '*' &&
(!in_array($this->fileInfo['suffix'], $mimetypeArr) || (stripos($typeArr[0] . '/', $this->config['mimetype']) !== false && (!in_array($this->fileInfo['type'], $mimetypeArr) && !in_array($typeArr[0] . '/*', $mimetypeArr))))
) {
throw new UploadException(__('Uploaded file format is limited'));
return false;
if ($this->config['mimetype'] === '*'
|| in_array($this->fileInfo['suffix'], $mimetypeArr) || in_array('.' . $this->fileInfo['suffix'], $mimetypeArr)
|| in_array($this->fileInfo['type'], $mimetypeArr) || in_array($typeArr[0] . "/*", $mimetypeArr)) {
return true;
}
return true;
throw new UploadException(__('Uploaded file format is limited'));
}
protected function checkImage($force = false)