Re: File and HTML document from one script

From: Date: Sat, 10 Jun 2000 00:41:11 +0000
Subject: Re: File and HTML document from one script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-1522@lists.php.net to get a copy of this message
In article <002a01bfcec6$1b9a3280$0b2b3b8d@rz.fhulm.de>, rahlfs@fh-ulm.de ("Dietmar Rahlfs") wrote: > I want to download a file with IE5 and NN4.72 under > Windows 98. Simultanously I want to make appear the > "Save as" window and an HTML page in the original > browser window. The name of the file to save should > be set to be the original file name. > > I have coded the following: > > <?php > header("content-type: application/octet-stream"); > readfile("/bin/pwd"); > > header("something"); > ?> > HTML code > > I guess I have to close the document anyhow > before sending the second header, No. The second header has to come before the readfile. > Then the "Save as" windows takes as default > file name the name of the PHP script, and > even when is have changed the file type mask > to *.* "pwd" gets saved as "pwd..php3". > > At last, a bit off-topic: Although I sent > "application/octet-stream" as content type > the file content appears in the IE5(!) browser > windows when I want to download a text or > HTML file. Can I change this behaviour? You need 'Content-type:' not 'content-type:' You also may need Content-disposition and several other headers to make all browsers behave: Search code archives for Content-type and you'll find them all. Also need to use a URL that looks like: http://yourserver.com/whatever.php3/whatever.doc The bogus ending there will fool one of the stupid browsers that the file should be named whatever.doc when it's downloaded. -- Richard Lynch | If this was worth $$$ to you, buy a CD US Customer Support Director | from one of the artists listed here: Zend Technologies USA | http://www.L-I-E.com/artists.htm http://www.zend.com | (this has nothing to do with Zend, duh!)

« previous php.general (#1522) next »