From cc5805f410e6af7c3d64736ff314cbf4a4eb16fb Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Sun, 28 Jun 2020 08:34:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchUpload.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/extend/catcher/CatchUpload.php b/extend/catcher/CatchUpload.php index cda4cad..edc7a6a 100644 --- a/extend/catcher/CatchUpload.php +++ b/extend/catcher/CatchUpload.php @@ -61,7 +61,8 @@ class CatchUpload $path = Filesystem::disk($this->getDriver())->putFile($this->getPath(), $file); if ($path) { - $url = self::getCloudDomain($this->getDriver()) . $path; + + $url = self::getCloudDomain($this->getDriver()) . '/' . $this->getLocalPath($path); event('attachment', [ 'path' => $path, @@ -76,6 +77,15 @@ class CatchUpload throw new FailedException('Upload Failed, Try Again!'); } + protected function getLocalPath($path) + { + if ($this->getDriver() === self::LOCAL) { + return str_replace(root_path('public'), '', \config('filesystem.disks.local.root')) . DIRECTORY_SEPARATOR .$path; + } + + return $path; + } + /** * 多文件上传 *