note 21708 added to function.header
| From: | dpiper at stens dot com | Date: | Thu, 23 May 2002 21:34:48 +0000 |
| Subject: | note 21708 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30958@lists.php.net to get a copy of this message | ||
For inline images (JPEG for example):
header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename=file.jpg);
For attachments (Adobe PDF for example):
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename=file.pdf);
NOTE: In Internet Explorer, the Content-Disposition header is important, otherwise it will be
inline. 'Content-Disposition: attachment' will ALWAYS make IE download it.
NOTE: In Netscape, if you want to force it to be a download (i.e. not inline), use
header('Content-Type: application/octet-stream').
Netscape doesn't appear to care about the Content-Disposition header apart from when it's
in an email message, then the header controls behaviour as expected.
It's best to be specific about the file you're sending. Don't rely on the
interpretation of the browsers in the face of missing or default headers.
Content-Length is good to set for downloads, since it will allow the browser to show a progress
meter. It has to be accurate otherwise the browser will stall in downloading.
--
http://www.php.net/manual/en/function.header.php
http://master.php.net/manage/user-notes.php?action=edit+21708
http://master.php.net/manage/user-notes.php?action=delete+21708
http://master.php.net/manage/user-notes.php?action=reject+21708