homepage Welcome to WebmasterWorld Guest from 54.234.147.84
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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?
pelachrum




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

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

 

Stefan




msg:571004
 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?

encyclo




msg:571005
 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:

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

rocknbil




msg:571006
 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