誰もが http 経由でアクセスできるフォルダーである「public_html」の外部からユーザーにファイルをアップロードするのに問題があります。元。www.website.com/ / の後のすべてが 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
に、ファイルのダウンロードではなく、.