Re: Sending files to the user...?

From: Date: Tue, 05 Feb 2002 12:36:17 +0000
Subject: Re: Sending files to the user...?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83583@lists.php.net to get a copy of this message
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 "); > > ?> > >

« previous php.general (#83583) next »