Return to Snippet

Revision: 10574
at January 5, 2009 06:29 by fruehjahr

Initial Code
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

Initial URL

Initial Description
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.

Initial Title
Force downloading of a file

Initial Tags
image, download

Initial Language