Page 1 of 1

Force download script

Posted: Sat Oct 18, 2008 1:44 am
by shubham_amola
i want to force a file to download instead of opening it in browser or acrobat...ny advice????

Re: Force download script

Posted: Sat Oct 18, 2008 1:54 am
by requinix
If $filename is the path to the file you want downloaded:

Code: Select all

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($filename));
readfile($filename);
exit;