Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <a href="download_file.php?file=ficheiro_xls/BD%20Fugas%20Gespost.xls">Download XLS</a>
  2.  
  3. <?php
  4. header("Content-Type: application/octet-stream");
  5.  
  6. $file = $_GET["file"];
  7. header("Content-Disposition: attachment; filename=" . urlencode($file));
  8. header("Content-Type: application/octet-stream");
  9. header("Content-Type: application/download");
  10. header("Content-Description: File Transfer");
  11. header("Content-Length: " . filesize($file));
  12. flush(); // this doesn't really matter.
  13. $fp = fopen($file, "r");
  14. while (!feof($fp))
  15. {
  16. echo fread($fp, 65536);
  17. flush(); // this is essential for large downloads
  18. }
  19. fclose($fp);
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement