Re: File Download Headers
| From: | Richard Lynch | Date: | Fri, 16 Jun 2006 01:15:05 +0000 |
| Subject: | Re: File Download Headers | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238129@lists.php.net to get a copy of this message | ||
On Thu, June 15, 2006 10:17 am, Jon Anderson wrote:
> Richard Lynch wrote:
>> Can any experts on this list explain to me why, despite the
>> 1,000,000
>> places that application/octet-stream is documented to work, and has
>> always worked, since Mosaic 1.0 days, people manage to find these
>> goofball Content-type: headers that are supposed to work, but only
>> work in a handful of browsers, and then they write tutorials as if
>> it's the Right Way, and then those tutorials get past alleged
>> Editors,
>> and are all you can find from Google?
>>
>> Anybody?
> Well, I can't vouch for any goofballs, their editors, nor google, but
> unfortunately sometimes an alternative to application/octet-stream has
> to be used to work around brokenness in certain versions of IE...We
> used
> octet-stream, and had a small portion of users complaining because
> they
> couldn't open the file that was downloaded - "I can't open
> download.php", hence the workaround.
But they downloaded it.
They HAVE the data, it's just got a filename they don't know what to
do with.
If they just change the extension to whatever it should be, it would
be fine.
> - We can't use download.php?/filename.ext - (long story, but suffice
> it
> to say that it can't be done for non-technical reasons.)
Well, then, you've just eliminated a correct technical solution for
non-technical reasons...
I cannot do much about that...
Actually, if you REALLY want to be browser-compliant back to the stone
age, and througout the dreaded 3.x and 4.x series, you would need to
get the URL to be just:
http://example.com/script_that_looks_like_dirname/filename.ext
That odd-looking dirname is a PHP script.
URL juggling with mod_rewrite ForceType and $_SERVER['PATH_INFO'] is
the tech.
The browser then CANNOT screw up beause it "looks" like a static URL.
> - IE doesn't take the Content-Disposition in some cases unless you use
> a
> different content-type.
>
> Our code basically does this:
>
> if (IE) {
> use wrong content type;
> if (IE 5.5) {
> use broken content disposition;
> } else {
> use normal content disposition;
> }
> } else {
> do things in a standard way;
> }
My code basically looks like this:
header("Content-type: application/octet-stream");
Though, admittedly, the 3 lines in .htaccess should "count"
And, if you want input parameters in the URL instead of GET (which
will mess up FDF files) then there's another 20 lines to parse
$_SERVER['PATH_INFO'] into an array, just like $_GET and $_POST, only
not.
But then, that code is in an include file and gets re-used for a lot
of different rich media (images, PDF, Ming flash movies, etc) so it's
got a decent re-use factor.
Maybe I'm just re-using code from 5 years ago that could be replaced
by the browser-detecting (assuming the user-agent doesn't lie) and
using some new-fangled headers...
Or I could just keep using the code that cannot break. Yeah, I like
that.
--
Like Music?
http://l-i-e.com/artists.htm