Re: Force Download file to Mac i.e.

From: Date: Wed, 11 Oct 2000 15:30:57 +0000
Subject: Re: Force Download file to Mac i.e.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19603@lists.php.net to get a copy of this message
In article <NHBBJOAGKLMACKDJOLLBCEHFCEAA.l.smith@sixforty.co.uk>, l.smith@sixforty.co.uk ("Leigh Smith") wrote: fname=$filename.".jpg"; > > $fp = fopen($fname, "r"); > header("Content-type:application/octet-stream"); > header("Content-Disposition: attachment; filename=$fname"); > fpassthru($fp); > > How can I force the name on the mac !! Here's what I do; note that your Content-type: is missing a space after the colon. I don't know if its required, but I wouldn't be surprised if it triggers problems in some browsers. <?php $mimetype = getmimetype($filename); header("Content-type: $mimetype"); header("Content-Disposition: attachment; filename=\"$filename\""); readfile("$filepath/$filename"); ?> getmimetype() just determines the mime type for the file based on its extension. This way, the Mac knows what kind of a file it is: a jpeg, a PDF, whatever. You would have to write your own such function (I just grab and parse the mime type list that comes with Apache). Note the quotes around the filename might also solve some issues. However, this works in Netscape and Lynx, but not iCab (which simply displays the file; presumably it doesn't understand content-disposition), or Internet Explorer (which will download the file, but not give it the correct default filename). If working in Internet Explorer is important, suggest it as a feature addition to the Macintosh Internet Explorer team, and in the meantime recommend the use of Netscape for your Mac users. Jerry

« previous php.general (#19603) next »