From 32d8336becade6baea85eff8b1d62b21b9d57221 Mon Sep 17 00:00:00 2001 From: filesite Date: Sat, 29 Oct 2022 17:49:59 +0800 Subject: [PATCH] improve image type check --- controller/ApiController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/controller/ApiController.php b/controller/ApiController.php index 9e501f5..b234fbe 100644 --- a/controller/ApiController.php +++ b/controller/ApiController.php @@ -610,14 +610,19 @@ Class ApiController extends Controller { return ''; } - return strtolower(array_pop($arr)); + $suffix = array_pop($arr); + if (in_array($suffix, ['jpg', 'jpeg'])) { + $suffix = 'jpg'; + } + + return strtolower($suffix); } //从文件类型中解析文件后缀 protected function getSuffixFromFileType($fileType) { $arr = explode('/', $fileType); if (count($arr) < 2) { - return ''; + return $fileType; } $suffix = array_pop($arr);