10-06-2004, 03:33 PM
Munkay,Oct 6 2004, 09:23 AM Wrote:My HTML skills are a few years rusty, but I do beleive it is possible to create a link that opens the 'save' command in broswers. Maybe I'm making that up though.
[right][snapback]57111[/snapback][/right]
It all depends on how the server deals with the apparent extension of the file, and if the server doesn't supply much of the how-to then the browser will try to deduce what to do with the file. Save dialogue is initiated for extensions for which it makes sense to save the file (the browser has a set of defaults for these too).
You are correct you can make up a script that just overrides the file type decision making by setting: 'Content-type' header.
Following which a stream of data forming the file can be just shoved into the HTTP open stream. The browser will deal with it.
More info here.
MEAT's links work because the server correctly set HTTP header: "Content-Type" for the files based on either the extension of the magic of the file.
$ wget --spider --server-response http://members.cox.net/meat/GUIDE-Freeze%20a%20din.doc
- http://members.cox.net/meat/GUIDE-Freeze%20a%20din.doc
=> `GUIDE-Freeze%20a%20din.doc'
Resolving members.cox.net... done.
Connecting to members.cox.net[68.1.17.8]:80... connected.
HTTP request sent, awaiting response...
1 HTTP/1.1 200 OK
2 Date: Wed, 06 Oct 2004 15:22:55 GMT
3 Server: Apache/1.3.26 (Unix) FrontPage/4.0.4.3
4 Last-Modified: Mon, 04 Oct 2004 08:09:04 GMT
5 ETag: "1aac6c-5d202-41610520"
6 Accept-Ranges: bytes
7 Content-Length: 381442
8 Keep-Alive: timeout=15, max=100
9 Connection: Keep-Alive
10 Content-Type: application/msword
200 OK
Similarly for the .zip file it returned Content-Type: application/zip
The browser then has it easy to do the appropriate action for each.