[development] How do I send a file to the user?

Ernst Plüss ernst.pluess at gmail.com
Thu Feb 1 10:08:24 UTC 2007

I have no problem with not using die(). I first tried
http://api.drupal.org/api/5/function/drupal_set_header without
success. The only way to get rid of the "headers already sent" warning
was using die().
I think what you say about not using die() is exactly what is
necessary if you send a file with additional header information. You
have to make sure drupal isn't sending any other header information in
the same request later on.

So what should I do instead of calling die()?


2007/2/1, Johan Forngren <johan at forngren.com>:
> I might be wrong on this one, but I've always been told to never use die()
> in Drupal, since it stops code from the footer to be run. I recommend you to
> use  http://api.drupal.org/api/5/function/drupal_set_header
> to override drupal's headers.
> OT: Should we write a patch to remove that die()-call?
> On 2/1/07, Ernst Plüss <ernst.pluess at gmail.com > wrote:
> > Having a closer look at
> > http://api.drupal.org/api/5/function/_locale_export_po
> showed gave me
> > the solution.
> >
> > A die(); after sending out headers and excel data did the job. I don't
> > know exactly why this is needed, my guess is that if it's missing
> > somehow the next time a header is sent php thinks it belongs to the
> > same response and complains because already non header data has been
> > sent.
> >
> > Thanks a lot for your assistance!
> > Ernst
> >
> --
> Regards,
>   Johan Forngren
>   johan at forngren.com :: http://johan.forngren.com/

More information about the development mailing list