Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTTP/1.1 200 OK
- Proxy-Connection: Keep-Alive
- Connection: Keep-Alive
- Content-Length: 15872
- Via: **** // proxy server name
- Expires: 0
- Date: Tue, 20 Oct 2009 22:41:37 GMT
- Content-Type: application/vnd.ms-excel
- 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
- Cache-Control: private
- Pragma: no-cache
- Last-Modified: Tue, 20 Oct 2009 22:41:37 GMT
- Content-Disposition: attachment; filename="myFile.xls"
- Vary: Accept-Encoding
- Keep-Alive: timeout=5, max=100
- // assume you have a full path to file stored in $filename
- if (!is_file($filename)) {
- die('The file appears to be invalid.');
- }
- $filepath = str_replace('\', '/', realpath($filename));
- $filesize = filesize($filepath);
- $filename = substr(strrchr('/'.$filepath, '/'), 1);
- $extension = strtolower(substr(strrchr($filepath, '.'), 1));
- // use this unless you want to find the mime type based on extension
- $mime = array('application/octet-stream');
- header('Content-Type: '.$mime);
- header('Content-Disposition: attachment; filename="'.$filename.'"');
- header('Content-Transfer-Encoding: binary');
- header('Content-Length: '.sprintf('%d', $filesize));
- header('Expires: 0');
- // check for IE only headers
- if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))) {
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- } else {
- header('Pragma: no-cache');
- }
- $handle = fopen($filepath, 'rb');
- fpassthru($handle);
- fclose($handle);
Add Comment
Please, Sign In to add comment