Re: why did it stop working?

From: Date: Tue, 13 Mar 2007 01:04:30 +0000
Subject: Re: why did it stop working?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-250369@lists.php.net to get a copy of this message
On Thu, March 8, 2007 4:57 am, Ross wrote: > > Can someone explain to me why this used to work but then stopped > > header("Content-length: $size"); > header("Content-type: $type"); > header("Content-Disposition: attachment; filename=$name"); > > and this now works > > header("Content-length: ".$size); > header("Content-type: ".$type); > header('Content-Disposition: attachment; filename="'.$name.'"'); > echo $content; > > > Any suggestions? It never worked properly the first time around, but you never noticed the lack of quotes around "$name" because none of your filenames had spaces or other "interesting" characters in them. It only "breaks" when your $name has something other than a printable character. Actually, Content-Disposition also only works on newer browsers, but that's another story... If you want to force a download, the only correct type is application/octet-stream. If you want EVERY browser ever made to do the right thing for that "Save As..." popup, then Content-Disposition is not the way to go, as it won't work on legacy [*] browsers. I ranted about this a big long time ago here: http://richardlynch.blogspot.com * There may not BE any real users of said legacy browsers any more, mind you, but there it is. I got bit hard by this Content-disposition change and will never use it, no matter what decade we are in. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#250369) next »