diff --git a/app/Services/DocumentPreviewService.php b/app/Services/DocumentPreviewService.php index 9d6a558..8ea9f4b 100644 --- a/app/Services/DocumentPreviewService.php +++ b/app/Services/DocumentPreviewService.php @@ -80,8 +80,12 @@ class DocumentPreviewService // 获取文件的完整路径 $filePath = Storage::disk('local')->path($document->file_path); - // 设置 PHPWord 的临时目录 - Settings::setTempDir(storage_path('app/temp')); + // 确保临时目录存在并设置 PHPWord 的临时目录 + $tempDir = storage_path('app/temp'); + if (!is_dir($tempDir)) { + mkdir($tempDir, 0755, true); + } + Settings::setTempDir($tempDir); // 加载 Word 文档 $phpWord = IOFactory::load($filePath);