Enter your keyword

Download Files in PHP

Download Files in PHP

To downloads files in the php you need to use below code. just replace your file name with  akashwagh.pdf file

$filename = ‘akashwagh.pdf’;


// required for IE, otherwise Content-disposition is ignored
ini_set(‘zlib.output_compression’, ‘Off’);

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");

// change, added quotes to allow spaces in filenames

header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));




No Comments

Leave a Reply

Show Buttons
Hide Buttons