From 4346bfebb76a29028dc16da27bbe2c20ed846cde Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Tue, 2 Dec 2025 17:18:00 +0800 Subject: [PATCH] =?UTF-8?q?chore(src):=20=E4=BD=BF=E7=94=A8=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84=E6=9D=A5=E5=88=A4=E6=96=AD=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/model/upload/Upload.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/model/upload/Upload.php b/src/app/model/upload/Upload.php index 7ce365a18..c163ad5f3 100644 --- a/src/app/model/upload/Upload.php +++ b/src/app/model/upload/Upload.php @@ -890,17 +890,22 @@ class Upload extends BaseModel */ public function checkPath($path) { - $absolute_path = realpath($path); + $current_user = get_current_user(); + $current_user = $current_user ? $current_user : 'unknown'; + $current_work_dir = getcwd(); + $current_work_dir = $current_work_dir ? $current_work_dir : 'unknown'; + // 如果$path包含工作目录,需要转换为绝对路径 + $absolute_path = $path; + if (strpos($path, $current_work_dir) !== false) { + $absolute_path = $current_work_dir . "/" . $path; + } try { if (file_exists($absolute_path) || mkdir($absolute_path, 0755, true)) { return $this->success(); } } catch (\Exception $e) { - $current_user = get_current_user(); - $current_user = $current_user ? $current_user : 'unknown'; - $current_work_dir = getcwd(); - $current_work_dir = $current_work_dir ? $current_work_dir : 'unknown'; + return $this->error('', "上传目录 {$absolute_path} 创建失败,请检测权限:用户{$current_user},当前工作目录{$current_work_dir}," . $e->getMessage()); } }