From 3437415023f8570bac8f62af2a5dc4fd0cfc819b Mon Sep 17 00:00:00 2001 From: wuhaotian <442384644@qq.com> Date: Tue, 27 May 2025 14:24:42 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=A8=8B=E5=BA=8F=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E3=80=91=E6=9B=B4=E6=96=B0=E6=9C=AC=E5=9C=B0=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/crmeb/services/upload/storage/Local.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crmeb/crmeb/services/upload/storage/Local.php b/crmeb/crmeb/services/upload/storage/Local.php index b097d2828..2c5beea47 100644 --- a/crmeb/crmeb/services/upload/storage/Local.php +++ b/crmeb/crmeb/services/upload/storage/Local.php @@ -125,14 +125,16 @@ class Local extends BaseUpload if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) { return $this->setError('不合法的文件类型'); } - $stream = fopen($fileHandle->getPathname(), 'r'); - $content = (fread($stream, filesize($fileHandle->getPathname()))); - if (is_resource($stream)) { - fclose($stream); - } - $image = @imagecreatefromstring($content); - if ($image === false) { - return $this->setError('文件内容不合法'); + if (in_array($fileHandle->getOriginalMime(), ['image/x-icon', 'image/png', 'image/gif', 'image/jpeg', 'image/jpg'])) { + $stream = fopen($fileHandle->getPathname(), 'r'); + $content = (fread($stream, filesize($fileHandle->getPathname()))); + if (is_resource($stream)) { + fclose($stream); + } + $image = @imagecreatefromstring($content); + if ($image === false) { + return $this->setError('文件内容不合法'); + } } } if ($realName) {