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:[EMAIL PROTECTED]]
Sent: Tuesday, February 05, 2002 1:36 PM
To: [EMAIL PROTECTED]
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 [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
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.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php