RE: [PHP] Re: Sending files to the user...?
| From: | UGBI) | Date: | Tue, 05 Feb 2002 12:37:43 +0000 |
| Subject: | RE: [PHP] Re: Sending files to the user...? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-83584@lists.php.net to get a copy of this message | ||
Your are on the right track.....
Using the Header function is the way to do it.
But I guess you forget to take a look at the manual page. There are all
questions that you ask answered :)
So take a look http://www.php.net/manual/en/function.header.php
.
in short:
RFC: http://www.w3.org/Protocols/rfc2616/rfc2616
Force download:
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=downloaded.pdf");
/* ... output pdf file ... */
Kind Regards,
Jerry
> -----Original Message-----
> From: Alan McFarlane [mailto:amcfarlane@bigfoot.com]
> Sent: Tuesday, February 05, 2002 1:36 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: Sending files to the user...?
>
>
> Oh, and BTW, after sending the file, I will be redirecting
> the user to a
> different page...
>
> Alan McFarlane <amcfarlane@bigfoot.com> wrote in message
> news:20020205123242.23507.qmail@pb1.pair.com...
> > The problem:
> >
> > How to I send a file to the user? Sounds simple but, assume I have a
> 'daily
> > report' option from my main web page. When the user clicks
> on it, they are
> > taken to the file 'generate_report.php' (sample included).
> >
> > Now, this code should generate the report, compress it if
> required and
> send
> > it ot the user - i.e. a dialog box opens asking the user to
> open/save/run
> > the incoming file.
> >
> > Question is, how? - I've toyed with Content-Disposition but
> I'm not sure
> of
> > any reference materials for this. (Perhaps someone knows the RFC)
> >
> > The code:
> >
> > <?php
> > /* file: generate_report.php */
> >
> > // build the report
> > $report = "<xml...>"; /* basically an xml document
> >
> > // compress if possible
> > if (extension_loaded("zlib") && (strlen($report) > 1024))
> > {
> > $report = gzcompress($report);
> > $compress = true;
> > }
> > else
> > {
> > $compressed = false;
> > }
> >
> > $length = strlen($report); // I presume this can handle
> binary data
> >
> > // header(" something ");
> >
> > ?>
> >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
The information contained in this email is confidential and
may be legally privileged. It is intended solely for the
addressee. Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any
form of disclosure, production, distribution or any action
taken or refrained from in reliance on it, is prohibited and
may be unlawful. Please notify the sender immediately.
The content of the email is not legally binding unless
confirmed by letter bearing two authorized signatures.