Save As Q

C

Captain Dondo

(Apologies to those who also monitor c.l.javascript; this is being
multi-posted)

I'm searching for the most 'elegant' way to do this:

I pop up a window with a picture in it. The picture is a Thumbnail for
the full-size digital image. The fullsize digital image is too big to
fit on a typical user's screen.

What I would like is to prevent the browser (any browser, I know I have
to support IE, FireFox, and Mac-Safari at a minimum) from opening this
jpeg image in a new window, and instead ask the user if s/he wants to
save the file.... Doable? I guess what I am trying to do is turn off
the automatic mime-type handling for this one operation.....

Failing that, I am looking for the most elegant way of handling this.
I really don't want users to get a window that is 2 or 3 times their
screen size, just to save the file.....

Any thoughts?
 
M

Mitja

What I would like is to prevent the browser (any browser, I know I have
to support IE, FireFox, and Mac-Safari at a minimum) from opening this
jpeg image in a new window, and instead ask the user if s/he wants to
save the file.... Doable? I guess what I am trying to do is turn off
the automatic mime-type handling for this one operation.....

Failing that, I am looking for the most elegant way of handling this. I
really don't want users to get a window that is 2 or 3 times their
screen size, just to save the file.....

"Failing this" meaning you already failed or not? If you have, try again
:) - that's just about the only way of suggesting to the user's browser to
save the file rather than open it. And even then... I'm not sure about IE,
you'd have to try that. As for the others, I think they'll honor
content-type: application/octet-stream.
JS can't help you there, I'm 99% sure of it. Neither can anything else,
AFAIK - this is a FAQ and the common answer is simply "it can't be done".
And it certainly cannot be _forced_, but with an altered content-type, you
may come close.
Otherwise (i.e. if IE fails to cooperate) your best bet is to ask visitors
to right click the link and select "save target as" - not an uncommon
practice.
 
C

Captain Dondo

Mitja said:
"Failing this" meaning you already failed or not? If you have, try
again :) - that's just about the only way of suggesting to the user's
browser to save the file rather than open it. And even then... I'm not
sure about IE, you'd have to try that. As for the others, I think
they'll honor content-type: application/octet-stream.
JS can't help you there, I'm 99% sure of it. Neither can anything else,
AFAIK - this is a FAQ and the common answer is simply "it can't be
done". And it certainly cannot be _forced_, but with an altered
content-type, you may come close.
Otherwise (i.e. if IE fails to cooperate) your best bet is to ask
visitors to right click the link and select "save target as" - not an
uncommon practice.

Well, a *bunch* more googling uncovered this snippet:

http://www.php-editors.com/forum/index.php?act=Print&client=printer&f=10&t=1482&

I'll try it out and see if it works, but off-hand it looks just like
what I need....
 
O

Oli Filth

Captain Dondo said the following on 07/06/2005 17:08:
(Apologies to those who also monitor c.l.javascript; this is being
multi-posted)

Don't multi-post, cross-post instead!!
I pop up a window with a picture in it. The picture is a Thumbnail for
the full-size digital image. The fullsize digital image is too big to
fit on a typical user's screen.

What I would like is to prevent the browser (any browser, I know I have
to support IE, FireFox, and Mac-Safari at a minimum) from opening this
jpeg image in a new window, and instead ask the user if s/he wants to
save the file.... Doable? I guess what I am trying to do is turn off
the automatic mime-type handling for this one operation.....

Failing that, I am looking for the most elegant way of handling this. I
really don't want users to get a window that is 2 or 3 times their
screen size, just to save the file.....

Any thoughts?

Firstly, what's the point? Even if the user saves the picture, they'll
still have to open it in some program, and it'll still be bigger than
their screen.


But anyway, in PHP, you can "force" a "download" as follows (I don't
know how much support it has, but it works in IE6, Firefox and Opera 7.54):

<?php

header('Content-type: image/jpeg'); // or image/png, etc. as appropriate
header('Content-Disposition: attachment; filename="whatever.jpg"');
readfile('../images/whatever.jpg');

?>

I'm sure there'll be an equivalent in ASP-based languages, and Perl, and
other server-based languages.
 
C

Captain Dondo

Oli said:
Captain Dondo said the following on 07/06/2005 17:08:


Don't multi-post, cross-post instead!!

That's why the apology....
Firstly, what's the point? Even if the user saves the picture, they'll
still have to open it in some program, and it'll still be bigger than
their screen.

Well, I have a thumbnail. Clicking on the thumbnail opens a snapshot
(640x480, about 100K). If the user likes the snapshot, I want them to
be able to download the full size image, about 1MB. Then they can
print, edit, etc. to their hearts content. I just want this to be clean
and transparent during browsing; what they do with it afterward is their
problem.... Seriously, I'm thinking of users getting a high-res image to
print, v. the snapshot to view on screen.
But anyway, in PHP, you can "force" a "download" as follows (I don't
know how much support it has, but it works in IE6, Firefox and Opera 7.54):

<?php

header('Content-type: image/jpeg'); // or image/png, etc. as appropriate
header('Content-Disposition: attachment; filename="whatever.jpg"');
readfile('../images/whatever.jpg');

?>

Thanks, I've found a snippet that does something like that.... Now I
have to learn enough PHP to get it into my app.... :)
 
J

Jonathan N. Little

Oli Filth wrote:
Firstly, what's the point? Even if the user saves the picture, they'll
still have to open it in some program, and it'll still be bigger than
their screen.
<snip>

Well not necessarily, depends on what program you open the image with.
Now I am not advocating what he wants to do, but images on the web and
web browsers typically display images independent of their DPI setting.
E.g., a 300x300 pixel image on a typical monitor resolution about @96DPI
will mean the image will appear about 3" on a side, but an image set for
printing, typically 300DPI, using any decent graphic software would
recognize the files DPI setting and print a mere postage stamp 1" image.
Therefore if he is trying to supply 4"x6" printer resolution images
for download and printing, these images without some special browser
setting as 'Fit large images to browser windows' being set would appear
a huge 1200x1800 pixels on most folks monitors without HTML with WIDTH
and HEIGHT parameters forcing constrainment.
 
C

Captain Dondo

Jonathan said:
Well not necessarily, depends on what program you open the image with.
Now I am not advocating what he wants to do, but images on the web and
web browsers typically display images independent of their DPI setting.
E.g., a 300x300 pixel image on a typical monitor resolution about @96DPI
will mean the image will appear about 3" on a side, but an image set for
printing, typically 300DPI, using any decent graphic software would
recognize the files DPI setting and print a mere postage stamp 1" image.
Therefore if he is trying to supply 4"x6" printer resolution images for
download and printing, these images without some special browser setting
as 'Fit large images to browser windows' being set would appear a huge
1200x1800 pixels on most folks monitors without HTML with WIDTH and
HEIGHT parameters forcing constrainment.

Bingo! That and the fact that the 640x480 images are typically 100K,
and the full size images are about 1MB that. No point in someone
downloading 10 or 100 MB of pics when they might only be interested in 1
picture after seeing the 640x480 snapshots.

Anyway, the way the page is set up now, it pops up the standard
download/save as/open with dialog box, so the visitor can save it or
open it in their favorite program. That way, everyone is happy. I
don't want to force people into a large download if they really don't
want the pic, and I don't want to use up my bandwidth for nothing.
 
J

Jonathan N. Little

Captain said:
Bingo! That and the fact that the 640x480 images are typically 100K,
and the full size images are about 1MB that. No point in someone
downloading 10 or 100 MB of pics when they might only be interested in 1
picture after seeing the 640x480 snapshots.

Anyway, the way the page is set up now, it pops up the standard
download/save as/open with dialog box, so the visitor can save it or
open it in their favorite program. That way, everyone is happy. I
don't want to force people into a large download if they really don't
want the pic, and I don't want to use up my bandwidth for nothing.
Or you can use a small WB size image about 300 pixels as a viewable
preview that is linked to a hires image and you can label your preview
image info that the hires is 1Mb and xxxxx X xxxxx pixels and they can
click or right-click as the user so wishes dto download the image....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,129
Latest member
FastBurnketo
Top