Welcome to WebmasterWorld Guest from 184.73.3.107

Forum Moderators: incrediBILL

How do I force the download of image files?

   
10:11 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



when you click a link that leads to an image file
(http://www.........../image.jpg)
it opens in a new window/tab

is there a way to force the image to download as if it was a file, the download box would open up I mean?

does it have to reside in ftp or something...?

1:01 am on Jan 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Browsers recognize jpg URL's and hand them over just like a .htm, so I don't think you can force it on the user-end (not positive on that, though). Maybe you could do it with a server-side script somehow?
10:47 am on Jan 23, 2006 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I'm a little confused by your post, do you want a download prompt to appear and the image to be downloaded to a location on the user's hard drive, or you you want the image to open or be displayed in a pop-up window?

If the former, you can attempt to force the download of files if the server is running Apache: see this recent thread in the Apache server forum:

[webmasterworld.com...]

If it is the latter you want, you will need to use Javascript to open a new window from a link in an HTML page.

4:52 am on Jan 24, 2006 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The problem is that browsers will "sniff out" the file, even if you change the extension, and try to manage it accordingly. To effectively force the download of a known MIME type, you need to deliver it via server side programming and "munge" the content-type header. This makes the browser force the download dialogue.

See my post in this thread [webmasterworld.com], this works.

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month