diff --git a/ImiServer/Service/Upload.php b/ImiServer/Service/Upload.php index b97c0a7a67606d11dfabe7ab46c9f6351c11714d..9e7d951280c45a0e07735b2212dc1a9747f9adcb 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));