[myad1] Everyone likes to download files from online but there is a script which helps us download any files from a server. It’s a magic right? Yes, if you use below code then download magic will be happening.
To download files using the PHP code, you need to use below code. just replace your file name with an about-unity-blogger.pdf file and place it.
<?php $filename = 'about-unity-blogger.pdf'; $ctype="application/[extension]"; // required for IE, otherwise Content-disposition is ignored if(ini_get('zlib.output_compression')) 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)); readfile("$filename"); exit(); ?>
Here is a demo to see how it works.