So, I am trying to mask the download source from users, and this code seems to be convention for doing that.
The problem that I keep getting is that the file has no data -- 0 bytes.
Also, the file won't open in its default application (i.e. mp3 not opening in Winamp, etc.), but I'm sure this is due to the other problem.
Any ideas?
<?php
$req = $_REQUEST[req];
$file = './directory/'.$req;
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
?>