Re: why did it stop working?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux