Skip to content
Advertisement

Force download image from different server html

I have a link, that after click the link, user can download image. Right now, after click the link, user only can viewed the image.

How can I make browser to make after user click link, it will force to download the image

Here’s the code

JavaScript

I’ve tried added php code from here and here in below my html code, but it’s not working.

Advertisement

Answer

You can try this. I have tested on my localhost and it worked.

html:

JavaScript

download.php

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement