Guest User

Untitled

a guest
Apr 25th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. HTTP/1.1 200 OK
  2. Proxy-Connection: Keep-Alive
  3. Connection: Keep-Alive
  4. Content-Length: 15872
  5. Via: **** // proxy server name
  6. Expires: 0
  7. Date: Tue, 20 Oct 2009 22:41:37 GMT
  8. Content-Type: application/vnd.ms-excel
  9. Server: Apache/2.2.11 (Unix) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_python/3.3.1 Python/2.5.2 SVN/1.4.6 mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0
  10. Cache-Control: private
  11. Pragma: no-cache
  12. Last-Modified: Tue, 20 Oct 2009 22:41:37 GMT
  13. Content-Disposition: attachment; filename="myFile.xls"
  14. Vary: Accept-Encoding
  15. Keep-Alive: timeout=5, max=100
  16.  
  17. // assume you have a full path to file stored in $filename
  18. if (!is_file($filename)) {
  19. die('The file appears to be invalid.');
  20. }
  21.  
  22. $filepath = str_replace('\', '/', realpath($filename));
  23. $filesize = filesize($filepath);
  24. $filename = substr(strrchr('/'.$filepath, '/'), 1);
  25. $extension = strtolower(substr(strrchr($filepath, '.'), 1));
  26.  
  27. // use this unless you want to find the mime type based on extension
  28. $mime = array('application/octet-stream');
  29.  
  30. header('Content-Type: '.$mime);
  31. header('Content-Disposition: attachment; filename="'.$filename.'"');
  32. header('Content-Transfer-Encoding: binary');
  33. header('Content-Length: '.sprintf('%d', $filesize));
  34. header('Expires: 0');
  35.  
  36. // check for IE only headers
  37. if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))) {
  38. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  39. header('Pragma: public');
  40. } else {
  41. header('Pragma: no-cache');
  42. }
  43.  
  44. $handle = fopen($filepath, 'rb');
  45. fpassthru($handle);
  46. fclose($handle);
Add Comment
Please, Sign In to add comment