A web page question!
Author
Discussion

egomeister

Original Poster:

7,576 posts

290 months

Sunday 19th January 2003
quotequote all
Just a quick one...

When writing a web page does anyone know how you make file download? ie. the user clicks on a link, but instead of the file opening in the current window it opens one of the "save as" dialogue boxes.

Thanks in advance!

miniman

29,811 posts

289 months

Sunday 19th January 2003
quotequote all
Don't think there's a simple way. If Windows recognises that it can open the file inside IE, then it will do so. The only option is to right-click and choose Save As...

There is probably a clever way to do it with Javascrpt but I don't know it...

Bodo

12,557 posts

293 months

Sunday 19th January 2003
quotequote all
Normally, the browser interprets the link, and decides what to do:
in most cases, a compressed *.zip-file will be offered for download via a dialog.

Alternatively, you could supply a MIME-type, so the browser knows the file type:

Source:

<p><a href="einsundeins.xls" type="application/msexcel"><b>einsundeins.xls</b></a>
</p>


egomeister

Original Poster:

7,576 posts

290 months

Sunday 19th January 2003
quotequote all
Ah bodo, i think i have been a bit ambiguous on my original post - what I am trying to do force it to use the save as dialogue box rather than open it in the application. You have told me how to make it open in the application havent you?

Thanks!

Steve

Bodo

12,557 posts

293 months

Sunday 19th January 2003
quotequote all
As far as I understand, it depends on the browser's settings what happens to a file then.

My browser's (Mozilla 1.1) preferences allow to set what happens

When starting a download
a) Open the download manager
b) Open a progress dialog
c) Don't open anything

For openening files with the browser, one can specify them in the browser in the tab "Helper Applications"


When it is an unknown file, it automatically asks if I want to
a) Open with...
b) Save as...


IIRC, the savest way would be the zip-compression to solve the problem in html.

egomeister

Original Poster:

7,576 posts

290 months

Sunday 19th January 2003
quotequote all
Sounds like there is little i can do about it for a jpeg file then. Oh well, if this is what web design is like then i'm glad i'm studying automotive engineering!

Thanks

gopher

5,160 posts

286 months

Sunday 19th January 2003
quotequote all
If the browser has the ability (or thinks it has the ability based on the file extension) then it will try to display it - often seen with .doc and .xls when opened in IE, also with .pdf's when you have acrobat reader installed.

I think the only sure fire way is to include the file without an extension and hope the user is able to follow an instruction such as "rename the file ." once saved to disk.

Cheers

Paul

edited to say: Just seen your last post - sorry I think you have no chance with a jpeg - but by not having the .jpg extension it should work as described above or use an image type that browsers don't recognise but other image viewers can - but this can cause other problems which I'm sure you've already guessed at.

>> Edited by gopher on Sunday 19th January 16:39

egomeister

Original Poster:

7,576 posts

290 months

Sunday 19th January 2003
quotequote all
I'll just add a note to tell the user to right click and use save target as... its a lot less messy than renaming files and all that!

Bodo

12,557 posts

293 months

Sunday 19th January 2003
quotequote all
It's a *.jpg then.


If you visit the press areas on websites, they often offer images of the products in high resolutions.

The way, they make them downloadable is either zip'ed (as mentioned above), or they offer *.tif - images, which are not readable by common browsers, and offer better quality @ bigger file size.

Here is an example of a company which offers images as zip'ed *.tif.

srider

709 posts

309 months

Sunday 19th January 2003
quotequote all
It's technically possible, but a lot of hassle. You need a component or scrpt which can send a binary stream direct to the browser.

Just tell them to Right-click

Edited to fix speeling

>> Edited by srider on Sunday 19th January 17:23