diff --git a/extend/catcher/CatchUpload.php b/extend/catcher/CatchUpload.php index 4d685cadcb33bfb0f0319953e38a71a87bc7fca1..c704baa689d119f7e7f90be4c0b8105b703c1784 100644 --- a/extend/catcher/CatchUpload.php +++ b/extend/catcher/CatchUpload.php @@ -61,6 +61,8 @@ public function upload(UploadedFile $file): string try { $this->initUploadConfig(); + $file->hashName([$this, 'newFilePath']); + $path = Filesystem::disk($this->getDriver())->putFile($this->getPath(), $file); if ($path) { @@ -84,6 +86,17 @@ public function upload(UploadedFile $file): string } } + /** + * 文件上传路径 + * + * @time 2022年05月16日 + * @return string + */ + public static function newFilePath(): string + { + return date('Y/m/d') . DIRECTORY_SEPARATOR . md5(microtime(true) . uniqid((string)mt_rand(), true)); + } + /** * 上传到 Local *