"public_html"외부에서 사용자에게 파일을 업로드하는 데 문제가 있습니다.이 파일은 모든 사람이 http를 통해 액세스 할 수있는 폴더입니다. 전의. the/public_html 다음에 www.website.com/ everyhting. 나는 네가 내가 말하는 것을 모두 알고있을 것이라고 확신한다.피드 파일 public_html 외부
(서버 관점)/images/protected /에서 파일 (sample.pdf)을 읽어야하지만 PHP가 내 파일을 찾지 못합니다. 내가 잘못 했니?
<?php
$file = '/images/protected/sample.pdf';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
} else {
echo "404 - FILE NOT FOUND!<br />\n";
echo "File: $file";
}
?>
내가이 스크립트를 실행할 때마다 내가 대신 파일 다운로드의
404 - FILE NOT FOUND!<br />\n
를 얻을.
입니다. 정확한 경로가 맞습니까? "이미지"라는 디렉토리가 루트에 있다는 것이 이상하게 보입니다. – JJJ
httpd 프로세스에 해당 파일을 보거나 읽을 수있는 권한이 있습니까? – Tim
그는 절대 시스템 경로가 아닌 절대 웹 경로를 나열하고있을 것입니다. – Tim