如何修复PHP中的mpdf权限被拒绝

时间:2019-12-12 13:23:38

标签: php excel pdf mpdf phpspreadsheet

我尝试从XLSX数据创建PDF。我使用Mpdf和PhpSpreadsheet。 我收到此错误,我该怎么办?

我得到了以下代码:

$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile("Leistungsbericht/Vorlage_M4cM4rco.xlsx");
$Vorlage2=$reader->load("Leistungsbericht/Vorlage_M4cM4rco.xlsx");

$Vorlage2->getActiveSheet()->setShowGridLines(false);
$Vorlage2->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);

$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($Vorlage2, 'Mpdf');

$writer->save('Leistungsbericht/M4cM4rcotest.pdf'); 

和此致命错误:

Fatal error: Uncaught UnexpectedValueException: DirectoryIterator::__construct(/mnt/shared/tmp): 
failed to open dir: Permission denied in /mnt/web320/c1/88/59295888/htdocs/Test2/vendor/mpdf/mpdf/src/Cache.php:87 
Stack trace: 
0 /mnt/web320/c1/88/59295888/htdocs/Test2/vendor/mpdf/mpdf/src/Cache.php(87): DirectoryIterator->__construct('/mnt/shared/tmp') 
#1 /mnt/web320/c1/88/59295888/htdocs/Test2/vendor/mpdf/mpdf/src/Mpdf.php(9481): Mpdf\Cache->clearOld() 
#2 /mnt/web320/c1/88/59295888/htdocs/Test2/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php(96): Mpdf\Mpdf->Output('', 'S') 
#3 /mnt/web320/c1/88/59295888/htdocs/Test2/Leistungs2.php(78): PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf->save('Leistungsberich...')
#4 /mnt/web320/c1/88/59295888/htdocs/Test2/Leistungs2.php(182): hhh() #5 {main} thrown in /mnt/web320/c1/88/59295888/htdocs/Test2/vendor/mpdf/mpdf/src/Cache.php on line 87

0 个答案:

没有答案