[development] How do I send a file to the user?
Jeremy Epstein
jazepstein at gmail.com
Wed Jan 31 22:41:53 UTC 2007
On 2/1/07, Moshe Weitzman <weitzman at tejasa.com> wrote:
> no, thats not the right function. you just need to send the right http
> headers and then print out your excel data. see http://us2.php.net/header.
> you can use that function directly. no benefit to going through drupal here.
That's right, setting the HTTP headers is the key to doing this. The
most common way to force a file download prompt is to set the
'content-disposition' header, which you can do in PHP like this:
header('Content-Disposition: attachment; filename="downloaded.pdf"');
However, this is not officially part of the HTTP standard (although it
is widely supported), and it has issues with Internet Explorer. See
http://www.hanselman.com/blog/TheContentDispositionSagaControllingTheSuggestedFileNameInTheBrowsersSaveAsDialog.aspx
for more details.
Cheers,
Jaza.
More information about the development
mailing list