PDA

View Full Version : Making a link initiate a download rather than open text


turtle
2008-12-25, 15:07
I'm trying to have a file download from my server rather than open it as hieroglyphic text. Here is the link:
http://turtle2472.com/~leo/ROMs/Laurentius26/HTC%20Blackstone/L26_THDV2.rar

I'm pretty sure it's a simple thing to do but I just don't know how to do it. Thanks for any help. :)

curiousuburb
2008-12-25, 15:09
What's wrong with asking users to right click and 'save as'...?

turtle
2008-12-25, 15:10
What's wrong with asking users to right click and 'save as'...?

Most are dumb. You would be amazed at how many people want to flash their phone but don't understand basic computer use. Simple is better.

chucker
2008-12-25, 15:12
You need to set the server to send the correct content-type.

Write the following into a file named .htaccess that you place in that directory (or several layers higher):

AddType application/x-rar-compressed .rar

turtle
2008-12-25, 15:14
You need to set the server to send the correct content-type.

Write the following into a file named .htaccess that you place in that directory (or several layers higher):

AddType application/x-rar-compressed .rar

Perfect. Thanks chucker!

Fahrenheit
2008-12-25, 15:44
Holy crap. So everytime I get a webpage full of those squares and numbers when clicking on a file, I was actually supposed to right click, 'save as'??

I have so much internet to learn. :(

Brad
2008-12-25, 16:29
Holy crap. So everytime I get a webpage full of those squares and numbers when clicking on a file, I was actually supposed to right click, 'save as'??

Well, that or notify the web site's author to fix their shit as chucker described. It's not your fault; it's the web site's author's fault. Really. And you're certainly not the only person to have trouble with said sites.

chucker
2008-12-25, 16:30
What the Bradmeister said. :)








<Insert rant of how it's really Apache's fault for defaulting to text/plain in violation of the spec.>

turtle
2008-12-25, 16:32
Yeah, to say people are dumb is a bit harsh. I mentioned this thread to my wife and she informed me she fits in that category too. It really does fall on the host/site author rather than the end user. That's why I asked so I could fix it on my end rather than make my users do the work.

curiousuburb
2008-12-25, 18:14
You're not asking them to chop cordwood fer crissakes... just click the other finger. :\

Brad
2008-12-25, 18:49
You're not asking them to chop cordwood fer crissakes... just click the other finger. :\

You forget rule number one of UI design: users don't read instructions.

Either make it work as expected with a normal click or expect people to not get the file. If it doesn't "just work", some people will go back and try to figure out what went wrong, but most will just give up, probably assuming something is broken (which is a correct assumption to make).

chucker
2008-12-25, 18:58
You're not asking them to chop cordwood fer crissakes... just click the other finger. :\

UI issues aside, it just doesn't make sense to serve a binary file as plain text.

dmegatool
2008-12-25, 19:29
alt+click for the win !!

I noticed some weird behavior with the alt+click though. Like if you alt+click on a .ai file (illustrator) it download theFile.ai.txt ... It's just gay

But as Chucker pointed, it doesn't make sense at all. Binary files sound be an automaic download.

curiousuburb
2008-12-25, 19:38
I concur that the smart fix is at the server end... but chronic user laziness/apathy doesn't help.

Nobody reads instructions anymore. Fine. UI should be idiot-proof. Agreed.
But what happened to curiousity and creative problem solving?
Must we always cater to the lazy mofos? Couldn't we meet halfway?

If 'use rusty knife on grue' doesn't work, try another variation, dude!

</oldschooltroubleshootingrant>

Brad
2008-12-25, 19:50
I noticed some where behavior with the alt+click though. Like if you alt+click on a .ai file (illustrator) it download theFile.ai.txt ... It's just gay
The reason Safari plops the "txt" extension on the end is also due to the server incorrectly identifying the file as text instead of binary. In an effort to help the user, Safari adds the "missing" extension so Mac OS X (or more specifically Launch Services, I guess) will treat the file as the server indicated it should be: as text.

Aside: yes, it would be nice to be able to turn off this "helpful" feature.

turtle
2008-12-25, 20:07
So now my question is how many others am I likely to have to add to my .htaccess? Is there a list somewhere and .rar is the first I've encountered to not work right?

colivigan
2008-12-25, 21:38
Many Apache installations default the Content-Type to text/plain if the file extension isn't recognized.

This snippet is from the standard Apache httpd.conf file, but I think you could probably also put a "DefaultType application/octet-stream" directive in your .htaccess file.

# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value. If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain

Ryan
2008-12-26, 02:04
The reason Safari plops the "txt" extension on the end is also due to the server incorrectly identifying the file as text instead of binary. In an effort to help the user, Safari adds the "missing" extension so Mac OS X (or more specifically Launch Services, I guess) will treat the file as the server indicated it should be: as text.

Aside: yes, it would be nice to be able to turn off this "helpful" feature.Would you say this might be similar to a behavior I've encountered with my university's Moodle installation? When I download a .docx or .xlsx, Safari appends .dot or .xlt. They did some maintenance on the site, not relating to this, and that fixed it. They made some more changes a month later and it went back to that behavior.