I need to allow users to download files from a directory that is not
publicly accessible. To do this, I use a download script:
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$fil ename);
readfile($fullp ath);
I've also tried using header("Content-Type: application/force-download")
instead of header("Content-Type: application/octet-stream"), but get the
same results - the downloaded file gets corrupted and cannot be read.
If I move the same file to /public_html and point a link to
http://www.mysite.com/filename.zip, it downloads fine and does not get
corrupted.
Am I using readfile correctly? Is there a more reliable way to download
files from directories that are not publicly accessible?
Thanks in advance.
publicly accessible. To do this, I use a download script:
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$fil ename);
readfile($fullp ath);
I've also tried using header("Content-Type: application/force-download")
instead of header("Content-Type: application/octet-stream"), but get the
same results - the downloaded file gets corrupted and cannot be read.
If I move the same file to /public_html and point a link to
http://www.mysite.com/filename.zip, it downloads fine and does not get
corrupted.
Am I using readfile correctly? Is there a more reliable way to download
files from directories that are not publicly accessible?
Thanks in advance.
Comment