Tuesday 2 June 2015

Force file download

<?php
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.
 

0 comments:

Post a Comment