Downloadable links

Joined
Oct 27, 2000
Messages
597
Hey guys,

I'm not getting very far on figuring this out myself, I thought I'd ask here.

How do I make a hyperlink so that when a user clicks it, it will default to "save to disk" instead of attempting to open it in IE or whatever?

Thanks very much in advance!
 
I'm pretty sure you can't; that action is decided by the user's settings in their browser.
 
not entirely true. it *is* possible (using JavaScript) to control how a link is handled. I had to do this for a client of mine where he was posting the products his clients were buying in their online account and then they downloaded it at their liesure. My crux was that I had to ensure that the files were always "saved" instead of "opened."

I'm between classes right now and don't have time to really go into it, but it is possible. I'd read up on JavaScript re-direction and that'll put you in the right ballpark.

If I have time when I get home later, I'll post a more thorough discussion of it.
 
You need your server to set a http-header when responding to the request --

Content-Disposition: attachment; filename=whatever.ext
 
Damn, I was hoping it was a checkbox. I'll use your hints to keep peeking around.

Maybe if I give you more information... Firefox doesn't seem to handle my amature web building very well, and if someone clicks on one of my video links, it displays a pile of random text. If they right click "Save Link As", they can save it to their machine and watch it there fine.

What I would like to do, is make it so that when a user clicks my video link, it will automatically download, instead of attempt to play in the browser.

If this information doesn't change what I need to do, then I'll keep messing with it.

Thanks again
 
You may have mistakes in your html-code for embedding the video in the page, or the server may be sending the wrong MIME-type header with the video. With a link we could tell you more.
 
HeThatKnows said:
You need your server to set a http-header when responding to the request --

Content-Disposition: attachment; filename=whatever.ext

this does not work in some versions of IE. The best cross-browser way to do it would be via javascript redirection trickery as was mentioned earlier.

--KK
 
Bad MIME-type is the problem.
Code:
+++GET 526+++
GET [url]http://www.sabrenet.ca/video/05Denyelle%20play.wmv[/url] HTTP/1.0
Host: [url]www.sabrenet.ca[/url]
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

+++RESP 526+++
HTTP/1.0 200 OK
Date: Tue, 07 Jun 2005 08:51:03 GMT
Server: Apache/2.0.50 (Fedora)
Last-Modified: Sun, 05 Jun 2005 19:43:21 GMT
ETag: "edc009-1ba9388-ccae6840"
Accept-Ranges: bytes
Content-Length: 29004680
[b]Content-Type: text/plain; charset=UTF-8[/b]
Your server is sending the videos labeled as plain text. For WMV it should be

Content-Type: video/x-ms-wmv

KingKaeru, tell me more of this javascript redirection trickery.
 
Back
Top