From 7f9e33eb2a23bb59b46e4701b72d8b642e82aeb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B0=8F=E6=98=8E?= <2966980@qq.com> Date: Mon, 16 May 2022 09:05:19 +0000 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=94=B1=20Ymd=20=E6=94=B9=E4=B8=BA=20Y/m/d=EF=BC=8C?= =?UTF-8?q?=E5=A4=9A=E7=BA=A7=E7=9B=AE=E5=BD=95=E4=BE=BF=E4=BA=8E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchUpload.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/extend/catcher/CatchUpload.php b/extend/catcher/CatchUpload.php index 4d685cadc..c704baa68 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 * -- Gitee