Force file download

Forces a file download

<?
if (ini_get('zlib.output_compression')) {
	ini_set('zlib.output_compression', 'Off');
}
	
$ctype="application/force-download";

header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers 
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit;
?>

Usage

Set $filename to the full path of the file and paste the code below that.


Comments

Add your comment