fix: 修复文档预览临时目录权限问题
- 在设置 PHPWord 临时目录前先创建目录 - 确保临时目录存在并具有正确的权限(0755) - 修复服务器环境下 tempnam() 权限错误
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user