This commit is contained in:
toom1996
2025-07-29 11:46:08 +08:00
parent a8d4390ff3
commit 75e5e52245

View File

@ -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);