From 285095f80ff70d66e6fc2aef82f28c839abb7734 Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 13 Aug 2020 16:11:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E4=BC=A0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=85=8D=E7=BD=AEmimetype=E6=97=A0=E6=95=88=E7=9A=84B?= =?UTF-8?q?UG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/library/Upload.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/application/common/library/Upload.php b/application/common/library/Upload.php index 54f7afec..b759d3c4 100644 --- a/application/common/library/Upload.php +++ b/application/common/library/Upload.php @@ -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)