Forces a user to download a file, for e.g you have an image but you want the user to download it instead of displaying it in his browser.
header("Content-type: application/octet-stream");
// displays progress bar when downloading (credits to Felix ;-))
header("Content-Length: " . filesize('myImage.jpg'));
// file name of download file
header('Content-Disposition: attachment; filename="myImage.jpg"');
// reads the file on the server
readfile('myImage.jpg');
Wednesday, December 3, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment