I have simple download script (used for Wordpress file downloads
if($filesize) {
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\"");
readfile($file_url);
} else {
echo '<p>No file found</p>';
}
I want to prevent users from accessing download files by direct access to them, so if user types in the path in browser, file should not be accesible.
I've tried this with .htaccess but without results. It was blocking the file directly but also script won't download the file.
Any help?
Thanks!
$_SERVER['HTTP_USER_AGENT']can help