Re: How to simultaneously send HTML *and* start download?

From: Date: Wed, 22 May 2002 15:27:58 +0000
Subject: Re: How to simultaneously send HTML *and* start download?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-98748@lists.php.net to get a copy of this message
Following on from my mail yesterday, here are the results of testing Billy's multipart content method on Windows browsers (Windows 98 to be precise): * IE 6.0 displays the boundary markers and content-type headers inline and also the contents of myfile.foo instead of saving it to disk. * Netscape 6.2.2 displays the HTML correctly and prompts regarding whether myfile.foo should be saved to disk but then appears to do nothing. * Netscape 4.7 displays the HTML correctly and begins downloading the file, only prompting for where it should be saved when the download is complete. * Opera 6.0 displays the HTMl correctly and prompts for where you wish to save the file, but incorrectly uses the script name and not the file name as specified in the content-disposition header. (It is possible that the behaviour of both Netscape 4.7 and Netscape 6.2.2 was in part due to interaction with Norton Anti-Virus.) Hope this is informative and not spam. Best, Darren On Tue, 2002-05-21 at 21:02, Billy S Halsey wrote: > Hi, > > Here's the shell of a script I wrote a while back to do exactly what you > want: > > <?php > > header("Content-Type: multipart/mixed; boundary=\"-Boundary-12399\""); > > print "---Boundary-12399\r\n"; > print "Content-Type: text/html\r\n"; > print "\r\n"; > > // Your HTML code goes here > > print "\n"; > print "---Boundary-12399\r\n"; > print "Content-Type: application/octet-stream\r\n"; > print "Content-Disposition: attachment; filename=foo.tar.gz\r\n\r\n"; > readfile("./foo.tar.gz"); > > print "---Boundary-12399--\r\n"; > print "\r\n"; > > ?> > > > Note the format of the "Boundary" headers, especially the dashes. -- ====================================================================== D. D. Brierton darren@dzr-web.com www.dzr-web.com Trying is the first step before failure (Homer Simpson) ======================================================================

« previous php.general (#98748) next »