我制作了文件管理器应用程序 我尝试下载文件时遇到问题 上传目录中的文件和从我的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) –
您是否将权限更改为该目录? –