Posted By

coggla on 01/20/08


Tagged

file headers download content-disposition


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

uisluu
srpsco
tux-world


Force a file download


 / Published in: PHP
 

  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  

You need to login to post a comment.