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