//************************************** // Name: Force Download // Description:If you are annoyed with pdf's that open in the browser as I am here is a way to force the user to be prompted to download a file. Changed the $filename directory to the directory that you have all of your pdf, doc, or other binary files. Then just make a call for the file. Example (downdload.php?file=myFile.pdf) and it will prompt the user to open the file for save it to disk. // By: brian461 (from psc cd) // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //************************************** <?php if (isset($_GET['file'])) { $file = $_GET['file']; header("Content-Type: application/force-download\n"); header("Content-Disposition: attachment; filename=$file"); $filename = "/usr/local/apache2/htdocs/" . $file; $contents = fread(fopen($filename, "rb"), filesize($filename)); echo $contents; } else { echo "No file specified"; } ?>