diff --git a/app/Helpers/ArticleHelper.php b/app/Helpers/ArticleHelper.php index 8a29fd6..7ddad1d 100644 --- a/app/Helpers/ArticleHelper.php +++ b/app/Helpers/ArticleHelper.php @@ -7,6 +7,13 @@ class ArticleHelper { public static function saveImagesFromArticle(string $html, string $savePath = '/www/wwwroot/uploads/', string $srcPrefix = '/uploads/') { + if (!$savePath) { + $savePath = env('UPLOAD_ROOT', ''); + if (!$savePath) { + throw new \Exception('找不到存储图片的路径信息。'); + } + } + // 创建保存图片的目录,如果没有的话 if (!file_exists($savePath)) { mkdir($savePath, 0777, true);