Last Updated: February 25, 2016
·
1.978K
· anriettec

Simple PHP force-download for any MIME type

<?php
$file = $_GET['file'];
header("Content-disposition: attachment; filename=".$file);
header("Content-type: application/download");
readfile($file);

And that's it! Thank to this <a href="http://webdesign.about.com/od/php/ht/force_download.htm">How To Use PHP to Force a File Download</a> and this <a href="http://stackoverflow.com/questions/9511279/how-to-make-php-file-download">How to make php file download?</a> for the guidance.