From 97b2eafdae6efc22b8c0c7a27ffc6f87d09bbe6c Mon Sep 17 00:00:00 2001 From: WispX Date: Tue, 11 Aug 2020 15:52:07 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=8E=9F=E5=A7=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E5=91=BD=E5=90=8D=E8=A7=84=E5=88=99=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=8E=E5=85=B6=E4=BB=96=E8=A7=84=E5=88=99=E7=BB=84?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Upload.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/application/common/controller/Upload.php b/application/common/controller/Upload.php index edc5866c..1268d245 100644 --- a/application/common/controller/Upload.php +++ b/application/common/controller/Upload.php @@ -92,8 +92,7 @@ class Upload extends Controller // 当前储存策略 $currentStrategy = strtolower($this->group->strategy); - // 获取当前储存策略配置 - $pathname = strtolower($this->makePathname($image->getInfo('name'))); + $pathname = $this->makePathname($image->getInfo('name')); $cdnDomain = $currentStrategy . '_cdn_domain'; $domain = $this->request->domain(); @@ -236,15 +235,20 @@ class Upload extends Controller array_column($naming['path'], 'value'), $pathRule ), '/'); - if ($fileRule === '{original}') { - $file = $name; - } else { - $file = trim(str_replace( - array_column($naming['file'], 'name'), - array_column($naming['file'], 'value'), - $fileRule - ), '/') . '.' . get_file_ext($name); + + // 原始文件名单独处理 + foreach ($naming['file'] as &$item) { + if ($item['name'] === '{original}') { + $item['value'] = pathinfo($name, PATHINFO_FILENAME); + } } + + $file = trim(str_replace( + array_column($naming['file'], 'name'), + array_column($naming['file'], 'value'), + $fileRule + ), '/') . '.' . get_file_ext($name); + return $path ? ($path . '/' . $file) : trim($file, '/'); } }