chore(src): 更新上传的判断路径的逻辑

This commit is contained in:
2025-12-02 17:19:41 +08:00
parent 4346bfebb7
commit 64c92857a6
2 changed files with 8 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -894,11 +894,12 @@ class Upload extends BaseModel
$current_user = $current_user ? $current_user : 'unknown'; $current_user = $current_user ? $current_user : 'unknown';
$current_work_dir = getcwd(); $current_work_dir = getcwd();
$current_work_dir = $current_work_dir ? $current_work_dir : 'unknown'; $current_work_dir = $current_work_dir ? $current_work_dir : 'unknown';
// 如果$path包含工作目录,需要转换为绝对路径 // 如果$path不是以工作目录开头,需要添加工作目录
$absolute_path = $path; $absolute_path = $path;
if (strpos($path, $current_work_dir) !== false) { if (!strpos($path, $current_work_dir)) {
$absolute_path = $current_work_dir . "/" . $path; $absolute_path = $current_work_dir . "/" . $path;
} }
try { try {
if (file_exists($absolute_path) || mkdir($absolute_path, 0755, true)) { if (file_exists($absolute_path) || mkdir($absolute_path, 0755, true)) {