Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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.

"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.

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?

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=1The 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.

Thanks, that was exactly what I was looking for.
I thought it had something to do with the header, but wasn't sure.

![]() |
![]() |
![]() |

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