Re: force download in IE

From: Date: Tue, 21 Aug 2001 17:35:48 +0000
Subject: Re: force download in IE
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-63743@lists.php.net to get a copy of this message
Some versions of IE will "sniff" the file to determine what type it is rather than taking your word for it that you REALLY want to download the file. From my memory this is IE 4, and IE 5.5 where this is a problem. The way I dealt with this is to totally make up an application type that IE will not have a helper app for... such as "new/type" or whatever you want. This should then trick IE into forcing a download. The other trick I noted was that IE 5.5 doesn't like the "attachement" keyword in the Content-Disposition header. Don't ask me why, all I know is that it won't pick up the supplied filename if you include it. That is from my experiences in forcing download files and it seems to work out once you figure out every combination of what does/doesn't work for the various versions of IE. Netscape is always fine, and I haven't tried any others extensively. Fiddle with the various headers for the different IE browsers and you will get it to work. Tim Frank >>>>>>>>>>>>>>>>>> Original Message >>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<< On 20/08/01, 1:45:29 PM, dave@dminor.com (David Minor) wrote regarding Re: force download in IE: > on 8/20/01 12:07 PM, bill@billtron.com wrote: > This gave the same result: it launches the helper app. > Please help!! > Regards. > dm > > Have you tried this? > > > > header("Content-Type: application/x-octet-stream"); > > header("Content-Description: MP3 file"); > > > > David Minor wrote: > > > >> Can anybody tell me why this doesn't work in IE? I need to force download > >> mp3 files instead of IE5.5 trying to apply a helper app. This code works > >> fine for NN. > >> > >> // detect for MSIE bug > >> if (strstr($HTTP_USER_AGENT, "MSIE")) > >> $attachment = ""; > >> else > >> $attachment = " attachment;"; > >> > >> // stream file to user > >> header("Content-Type: application/octet-stream"); > >> header("Content-Disposition:$attachment filename=$filename"); > >> header("Content-Length: ".filesize($tmp_file)); > >> header("Content-Transfer-Encoding: binary"); > >> readfile($tmp_file);

« previous php.general (#63743) next »