fix: 后台图片上传路径bug
This commit is contained in:
@@ -171,6 +171,7 @@ class Upload
|
|||||||
'filesha1' => $image_model->file_sha1
|
'filesha1' => $image_model->file_sha1
|
||||||
]);
|
]);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
dump($th);exit;
|
||||||
return error($th->getMessage());
|
return error($th->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,23 +185,21 @@ class Upload
|
|||||||
*/
|
*/
|
||||||
private function checkPath($path): string
|
private function checkPath($path): string
|
||||||
{
|
{
|
||||||
|
$ok = false;
|
||||||
$filename = basename($path);
|
$filename = basename($path);
|
||||||
$dirname = dirname($path);
|
$dirname = dirname($path);
|
||||||
if (is_dir($dirname)) {
|
if (!is_dir($dirname)) {
|
||||||
$ok = false;
|
|
||||||
if (!file_exists($dirname)) {
|
|
||||||
$ok = @mkdir($dirname, 0755, true);
|
$ok = @mkdir($dirname, 0755, true);
|
||||||
} else if (!is_writable($dirname)) {
|
}
|
||||||
|
else if (!is_writable($dirname)) {
|
||||||
$ok = @chmod($dirname,0755);
|
$ok = @chmod($dirname,0755);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
return $dirname . '/' . $filename;
|
return $dirname . '/' . $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Exception('要上传目录不可用');
|
throw new \Exception("上传目标目录不可用");
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 文件名生成回调
|
* 文件名生成回调
|
||||||
|
|||||||
Reference in New Issue
Block a user