Posted by Rik on 01/12/07 18:36
rog wrote:
> I have a script that produces a report and I want to give my clients
> the option to download the report as a text file.
>
> Currently, the report page displays the report in the browser but has
> an option to 'Download as File' which, when clicked
> 1) resubmits the page
> 2) writes the report data to a text file called "ReportAllInfo.txt"
> (this seems to work fine)
> 3)appends some headers and starts the download.
>
> code snippet:
>
> function SendFile()
> {
> global $filename;
> header('Content-Type: application/octet-stream');
> header('Content-Disposition: attachment;
> filename="ReportAllInfo.txt"');
>
> // load the file to send:
> readfile("ReportAllInfo.txt");
> }
function SendFile()
{
global $filename;
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment;
filename="ReportAllInfo.txt"');
// load the file to send:
readfile("ReportAllInfo.txt");
//stop processing
exit;
}
--
Rik Wasmus
[Back to original message]
|