Is there a way to make a link download an image instead of opening in on the browser?

Recommended Answers

All 6 Replies

Yes, you can link to a page instead of the image file itself, then using server side code, code your response headers so that the image is downloaded as an attachment.

Can it be done using just html?

No, html is just markup. You have to either control this via server side code as I described above, or change the behavior on the web server regarding how it handles requests for .jpg|.png|.gif files.

Hey found this online. This seems to work just fine. Thanks!

<a href="link to file" download>Anchor Text</a>

Hmmm. Wasn't aware of this new HTM5 attribute. Take a look here at its current support. It's not widely supported by all browsers at the moment.

http://caniuse.com/download

<a href="path of ur link" download>Click to Download</a>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.