Guest User

php_file_download.php

a guest
Jul 18th, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2.  
  3. // do all your processing of info received to determine which file to send, etc..
  4.  
  5. $file = '/path/to/file/to/download.txt';
  6.  
  7. $filesize = filesize($file);
  8.  
  9. header('Content-Description: File Transfer');
  10.  
  11. header("Content-type: application/forcedownload");
  12.  
  13. header("Content-disposition: attachment; filename=\"filename to display.txt\"");
  14.  
  15. header("Content-Transfer-Encoding: Binary");
  16.  
  17. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  18.  
  19. header('Pragma: public');
  20.  
  21. header("Content-length: ".$filesize);
  22.  
  23. ob_clean();
  24.  
  25. flush();
  26.  
  27. readfile("$file");
  28.  
  29. exit;
  30.  
  31. ?>
Add Comment
Please, Sign In to add comment