Re: content type header for downloading files

From: Date: Thu, 30 Jan 2003 09:27:02 +0000
Subject: Re: content type header for downloading files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-133613@lists.php.net to get a copy of this message
At 02:04 30.01.2003, Dara Dowd said: --------------------[snip]-------------------- >$fname is the name of the file i want to download. It works in IE, as in the >name of the file to be downloaded appears correctly in the dialog box. I >changed 'application/octet' to 'application/octet-stream' and this had no >effect. --------------------[snip]-------------------- This is what I do to transmit a file for a save-as download, and it works in all browsers I know and have tested the same (Netscape, IE, Opera/Win; Mozilla, Konqueror et al. / Linux): header('Content-type: application/octet-stream'); header('Content-length: ' . strlen($this->export)); header('Content-Disposition: attachment' . (empty($fname) ? '' : ';filename="'.$fname.'.csv"')); echo $this->export; exit(); Note that it seems to be necessary to surround the filename using quotes to make it work correctly. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#133613) next »