我最近遇到了這個問題,正如你在圖片中看到的,我授予了所有檔案的各種權限,但我仍然收到這個錯誤。
這是代碼:
$zipdir=dirname(dirname(__FILE__)).'/tmp';
$zipname="$zipdir/$input[user]-".time().'.zip';
list($pdf,$pdfname)=test_pdf($request);
$zip=new ZipArchive();
if ($zip->open($zipname,ZipArchive::CREATE)!==true) return $error='Could not open zip archive for writing';
$zip->addFromString("pdf/$pdfname", $pdf->Output('','S'));
$zip->addFile("test-docs/",$testformname);
$zip->close();
if (!file_exists($zipname)) return $error='Could not create zip archive';
https://i.stack.imgur.com/kmxUg.png
這是日志:
PHP Warning: ZipArchive::close(): Failure to create temporary file: Permission denied in /var/www/html/test/app/test.php
你覺得有什么不對?
uj5u.com熱心網友回復:
問題剛剛解決!
我需要為此路徑中的整個“html”檔案夾授予 775 或更高權限:
“/var/www/ html /...”
不僅僅是其中的檔案和檔案夾,因為我完全嘗試過。
此外,不需要 apache:apache 權限,root 即可完成作業。
這條評論很有幫助:
move_uploaded_file 給出“無法打開流:權限被拒絕”錯誤
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/334786.html
