Posted By

damarev on 07/25/07


Tagged


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

willcodeforfood
skywalker
JimiJay
srpsco
haozi
fackz
jschilling


download file


 / Published in: PHP
 

  1. $FILE_NAME = "archivo.zip";
  2. $FILE_PATH = tempnam("/var/tmp", $FILE_NAME);
  3. $fh=fopen($FILE_PATH, "rb");
  4.  
  5.  
  6. if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
  7. $FILE_NAME = preg_replace('/\./', '%2e', $name, substr_count($FILE_NAME, '.') - 1);
  8.  
  9.  
  10.  
  11. header("Cache-Control: no-cache, must-revalidate");
  12. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  13. header("Pragma: ");
  14. header("Content-Length: " .(string)(filesize($fh)) );
  15.  
  16. header("Content-Type: application/octet-stream");
  17. header("Content-type: application/pdf");
  18. header("Content-Type: application/x-msexcel; name=\"$FILE_NAME\"");
  19.  
  20. //force download dialog with filename:
  21. header("Content-Disposition: attachment; filename=\"$FILE_NAME\"");
  22.  
  23. //images?
  24. header("Content-Disposition: inline; filename=\"$FILE_NAME\"");
  25.  
  26.  
  27. header("Content-Transfer-Encoding: binary\n");
  28.  
  29.  
  30.  
  31.  
  32. fpassthru($fh);
  33.  
  34. unlink($FILE_PATH);
  35.  
  36. // ???
  37. //return((connection_status()==0) and !connection_aborted());

Report this snippet  

You need to login to post a comment.