I have the following HAML code …
%ul
%li{‘class’ => list_item_L3}
%div{‘id’ => getting_started_div}
%span{‘id’ => getting_started_span}
%a{‘id’ => getting_started_a,
‘href’ => '/videos/msg_ralph2.shnelvar.wmv}
Shnelvar
The link displays correctly but IE8 and FireFox both attempt to play the
file instead of putting up a prompt to download the wmv.
How can I force a download rather than a play?
Ralph S. wrote in post #970593:
I have the following HAML code …
%ul
%li{‘class’ => list_item_L3}
%div{‘id’ => getting_started_div}
%span{‘id’ => getting_started_span}
%a{‘id’ => getting_started_a,
‘href’ => '/videos/msg_ralph2.shnelvar.wmv}
Shnelvar
The link displays correctly but IE8 and FireFox both attempt to play the
file instead of putting up a prompt to download the wmv.
How can I force a download rather than a play?
There are things you can do with HTTP headers. BUT PLEASE DON’T. In
most browsers, it is easy to download a document that is displayed in
the browser, but it is impossible to display in the browser a document
that is automatically downloaded.
By automatically downloading, you are depriving the user of the choice
of what he wants to do with that file. (You might want him to download
it, but he might prefer to take a quick listen in the browser before he
does so.). That’s a UI mistake. Again, don’t do it.
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Sent from my iPhone
Marnen Laibow-Koser wrote in post #970622:
By automatically downloading, you are depriving the user of the choice
of what he wants to do with that file. (You might want him to download
it, but he might prefer to take a quick listen in the browser before he
does so.). That’s a UI mistake. Again, don’t do it.
Ok … how do I allow them to do either? View locally or download, as
the user sees fit?
On Dec 25, 2010, at 2:41 PM, Ralph S. wrote:
as
the user sees fit?
Create two separate paths, and on one, force the download by setting
the file-type to application/binary or something equally un-playable.
On the other, let the file-type come naturally (default behavior). The
two different paths point to the same file, but one is kinked to
always be something that can’t be played in a browser.
Walter
Walter D. wrote in post #970659:
On Dec 25, 2010, at 2:41 PM, Ralph S. wrote:
as
the user sees fit?
Create two separate paths, and on one, force the download by setting
the file-type to application/binary or something equally un-playable.
No! Do not mess with MIME types, ever, for any reason like this. The
proper way involves the content-disposition header.
On the other, let the file-type come naturally (default behavior). The
two different paths point to the same file, but one is kinked to
always be something that can’t be played in a browser.
That is a terrible idea. The point of a MIME type is to tell what the
file is, not to play stupid
games like these.
Walter
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Sent from my iPhone
Ralph S. wrote in post #970656:
Marnen Laibow-Koser wrote in post #970622:
By automatically downloading, you are depriving the user of the choice
of what he wants to do with that file. (You might want him to download
it, but he might prefer to take a quick listen in the browser before he
does so.). That’s a UI mistake. Again, don’t do it.
Ok … how do I allow them to do either? View locally or download, as
the user sees fit?
Just provide an ordinary link. If the user wants to download, he can
use the browser’s Save command. I explained this in my earlier post.
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Sent from my iPhone