From a207d80bc05b60b413f1db3cab78a6797fa09d70 Mon Sep 17 00:00:00 2001 From: ftlh2005 Date: Tue, 16 Aug 2022 04:28:02 +0000 Subject: [PATCH] =?UTF-8?q?update=20ImiServer/Service/Upload.php.=20?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E6=96=B9=E5=BC=8F=E5=A2=9E=E5=8A=A0=E9=AB=98?= =?UTF-8?q?=E6=AC=BE=20=E5=A6=82=EF=BC=9Axxxx=5F100x100.png=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=9B=BE=E7=89=87=E6=A0=BC=E5=BC=8F:=20'jpg',=20'png'?= =?UTF-8?q?,=20'jpeg',=20'gif',=20'webp'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ftlh2005 --- ImiServer/Service/Upload.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ImiServer/Service/Upload.php b/ImiServer/Service/Upload.php index b97c0a7..9e7d951 100644 --- a/ImiServer/Service/Upload.php +++ b/ImiServer/Service/Upload.php @@ -61,7 +61,14 @@ class Upload return false; } if ($this->config['save'] == 'local') { - $filename = str_replace('//', '/', $this->config['root'] . '/' . date("Ymd", time()) . '/' . md5_file($file->getTmpFileName()) . '.' . $extension); + // 上传图片时,命名方式增加高款 如:xxxx_100x100.png + if (in_array($extension, ['jpg', 'png', 'jpeg', 'gif', 'webp'])) { + $_file = new SplFileInfo($file->getTmpFileName()); + $fileSize = getimagesize($_file->getRealPath()); + $filename = str_replace('//', '/', $this->config['root'] . '/' . date("Ymd", time()) . '/' . md5_file($file->getTmpFileName()) . '_'. $fileSize[0]. 'x'. $fileSize[1] .'.' . $extension); + } else { + $filename = str_replace('//', '/', $this->config['root'] . '/' . date("Ymd", time()) . '/' . md5_file($file->getTmpFileName()) . '.' . $extension); + } $path = File::path(App::get(AppContexts::APP_PATH), '/') . ltrim($filename, '/'); if (!file_exists(dirname($path))) { File::createDir(dirname($path)); -- Gitee