homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

How do I force the download of image files?

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

when you click a link that leads to an image file
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)

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)

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:


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)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved