Force a file download


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $file = $_GET["file"];
  2. $download = "http://www.ssn.flinders.edu.au/".$file;
  3.  
  4. if(ini_get('zlib.output_compression')) {
  5. ini_set('zlib.output_compression', 'Off');
  6. }
  7.  
  8. header("Pragma: public");
  9. header("Expires: 0");
  10. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  11. header("Cache-Control: private",false);
  12. header("Content-type: application/pdf");
  13. header("Content-Disposition: attachment; filename=".basename($download).";" );
  14. readfile("$download");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.