我製作了文件管理器應用程序 我嘗試下載文件時遇到問題 上傳目錄中的文件和從我的PHP臨時目錄中移動不繼承該文件夾的權限,所以我就在PHP錯誤日誌此錯誤readfile():無法打開流:在Windows Server IIS 8上拒絕訪問
PHP Warning: readfile(files/xxx.zip): failed to open stream: Permission denied in ...
當我進去IIS,進入安全選項卡,並應用繼承權限它的工作原理
<?php
set_time_limit(0);
ini_set('memory_limit', '2147483648');
$file = "files/".htmlspecialchars($_GET["file"]);
$quoted = sprintf('"%s"',addcslashes(basename($file),'"\\"'));
$size = filesize($file);
if (file_exists($file)) {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: force-download");
header("Content-Disposition: attachment; filename=".$quoted);
header("Content-Transfer-Encoding: binary");
header('Connection: Keep-Alive');
header("Content-Length: ".$size);
ob_clean();
flush();
readfile($file);
} else {
header("Location: fileNotFound.php?file=$file");
}
檢查權限 –
['無法打開流:權限被拒絕'錯誤 - Laravel](https://stackoverflow.com/q/23540083/6521116) –
您是否將權限更改爲該目錄? –