Home General Force Download in PHP

Force Download in PHP

Published on December 16, 2009 by in General

This script works in all browsers, including Internet Explorer! :)

if (strstr($_SERVER[‘HTTP_USER_AGENT’],"MSIE")) {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application-download");
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($ab_file));
} else {
header("Content-type: application-download");
header("Content-Length: ".filesize($ab_file));
header("Content-Disposition attachment; filename=".$filename);
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
© Copyright © 2012 · Web Development London UK · All rights reserved · Site hosted on the network
By using the site and/or making use of any of our services you agree to our Terms and Conditions