From 5404c82201af8d1ba9c300abb125bf2aeb1c3e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E9=BE=8D?= <695798354@qq.com> Date: Thu, 12 Aug 2021 07:51:39 +0000 Subject: [PATCH 1/2] update application/common/library/Upload.php. --- application/common/library/Upload.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/application/common/library/Upload.php b/application/common/library/Upload.php index 66afc1dc8..6c7eb62b5 100644 --- a/application/common/library/Upload.php +++ b/application/common/library/Upload.php @@ -36,6 +36,13 @@ class Upload protected $error = ''; + /** + * 保存文件的跟地址 + * + * @var string + */ + protected $saveRootPath = ROOT_PATH . 'public'; + /** * @var \think\File */ @@ -380,6 +387,17 @@ class Upload return $attachment; } + /** + * 设置保存文件的根地址 + * + * @param string $path + * @return self + */ + public function setSaveRootPath($path) { + $this->saveRootPath = $path; + return $this; + } + public function setError($msg) { $this->error = $msg; -- Gitee From a225c8e2828d888d78dee1e5fd0221c6ebd8c12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E9=BE=8D?= <695798354@qq.com> Date: Thu, 12 Aug 2021 07:59:51 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=A0=B9=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/library/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/common/library/Upload.php b/application/common/library/Upload.php index 6c7eb62b5..962e75ba9 100644 --- a/application/common/library/Upload.php +++ b/application/common/library/Upload.php @@ -332,7 +332,7 @@ class Upload $uploadDir = substr($savekey, 0, strripos($savekey, '/') + 1); $fileName = substr($savekey, strripos($savekey, '/') + 1); - $destDir = ROOT_PATH . 'public' . str_replace('/', DS, $uploadDir); + $destDir = $this->saveRootPath . str_replace('/', DS, $uploadDir); $sha1 = $this->file->hash(); -- Gitee