Computing.Net > Forums > Programming > web programming question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

web programming question

Reply to Message Icon

Name: XBrendanX
Date: January 26, 2004 at 03:16:31 Pacific
OS: Windows XP
Comment:

hello,

on websites when i click on an image link it displays the image in my browser but sometimes it pops up a download dialog box. from the site creator's point of view is this programmable or is it IE [probaly]screwed? please explain what goes on behind the scenes.

TIA



Sponsored Link
Ads by Google

Response Number 1
Name: anonproxy
Date: January 26, 2004 at 09:02:32 Pacific
Reply:

IE is set to open certain files of a given extension and download all others (there are a few other options in there). What is the difference between open and just download? Firstly, all things are downloaded, but not all are opened, or read/executed. IE usually leaves some indication that something was downloaded by having a download dialogue window or simply opening the file.

When IE requests a web location vs. a filename (say google.com/images vs. google.com/image.gif), different things can happen.

If a web location is requested, the server could run a script which pulls the file from somewhere else and sends it to the browser. This is usually done to obscure filenames or because they are catalogued in a database. Also, the server can have preset aliases so google.com/news could really direct to news.html.

As far as a web designer, you typically don't have to worry too much about this. If you want a new window for anything, just use javascript or target="_blank" appended in the anchor tag. Javascript provides more options like window size and position. If you want to use the existing window, just use a normal link.


0

Response Number 2
Name: brenchong21
Date: January 26, 2004 at 13:20:43 Pacific
Reply:

So does this have anything to do with POST and GET requests?


0

Response Number 3
Name: anonproxy
Date: January 26, 2004 at 17:51:15 Pacific
Reply:

"So does this have anything to do with POST and GET requests?"

Yes, but in a static way. GET and POST are methods of sending data to the server from user input, part of the HTTP protocol. They are multipurpose, but don't affect this behavior. As a web programmer, you don't alter these arrangements, you just make use of them. A GET value is basically a URL, for example. But changing the URL, in and of itself, does not communicate to the browser to open an image or open a download window.

The behavior you asked about is usually determined by the browser.


0

Response Number 4
Name: Dr. Nick
Date: January 26, 2004 at 19:27:55 Pacific
Reply:

Alright, I actually have a question that I think is about the same, and at least along the same lines.

If you've ever used Yahoo Mail, you may have noticed this. If you get sent an attachment, it doesn't matter what the filetype is, .jpg, .exe, .zip, .gif, .doc it doesn't matter, when you click the download link it brings up the standard IE download box.

Normally IE treats different filetypes, or rather mimetypes differently. If you click a *.jpg link it will just open it in the browser. If you have Word installed and click a link to a *.doc file, it will open it in the browser. Same for files with 'plugins' like PDFs. Other files like *.zip and *.exe typically require confirmation before download.

Yahoo doesn't do this however. Doesn't matter what kind of file you try to download, IE always uses the standard file save box, with the Open, Save, Cancel, or More Info buttons. You will even get this if you are downloading an *.html file, or other web specific files.

Any ideas how this is done? How can you force a browser to download a file and not just display it?


0

Response Number 5
Name: anonproxy
Date: January 27, 2004 at 11:21:55 Pacific
Reply:

MIME types are just a wrapper around binary content. A format around a format.

A yahoomail image attachment has the following URL to display the image:
http://us.f215.mail.yahoo.com/ym/ShowFolder?rb=Inbox&YY=693904&.first=1&order=down&sort=date&pos=0&view=a&head=b&YN=1

The URL to download it is longer and specific to the message ID.

The server does not return an HTML page with the image. Instead, it probably is just altering the HTTP header. The server could be sending a custom or generic MIME type (application/ octet-stream), which most browsers can gloss over and discover the actual filetype. Most browsers can detect the file type correctly (even IE).

The best choice of MIME type is application/ force-download. A PHP script to force download windows is also availible. It refers to specifying the HTTP header with the PHP header() function.

So yes, you can force a download window. Glad you brought up Yahoomail.


0

Related Posts

See More



Response Number 6
Name: Dr. Nick
Date: January 27, 2004 at 15:38:00 Pacific
Reply:

Thanks, that was exactly what I was looking for.

I thought it had something to do with the header, but wasn't sure.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: web programming question

web programming www.computing.net/answers/programming/web-programming/57.html

Starting Web Programming www.computing.net/answers/programming/starting-web-programming/6745.html

A little web browsers I made www.computing.net/answers/programming/a-little-web-browsers-i-made-/11045.html