header("Content-type: application/octet-stream");
header("Content-Length: " . filesize('myImage.jpg'));
// displays progress bar when downloading (credits to Felix ;-))
// file name of download file
header('Content-Disposition: attachment; filename="myImage.jpg"');
// reads the file on the server
readfile('myImage.jpg');
2009年1月3日星期六
PHP Force downloading of a file
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.
订阅:
博文评论 (Atom)

没有评论:
发表评论