I've made a file manager application I have an issue when I'm trying to download files The files that are inside the uploads directory and have moved from my php temp directory dont inherit the folder permission so I got this error in php error log
PHP Warning: readfile(files/xxx.zip): failed to open stream: Permission denied in ...
When I go inside IIS and go into the security tab and apply inherit permissions it works
<?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");
}