Ask coding questions

← Back to all posts
download an image by clicking on it
19ecal (232)

i'm trying to make it so that you can download an image just by clicking on it
currently i have

<a href="/image1.jpg" download="image1.jpg">
    <img src="/image1.jpg">
</a>

but on clicking the image there is a warning Download is disallowed. The frame initiating or instantiating the download is sandboxed, but the flag ‘allow-downloads’ is not set. See https://www.chromestatus.com/feature/5706745674465280 for more details. in the console
how do i do this

Comments
hotnewtop
[deleted]

ok

<img src="https://theSourceOfYourImage.com/image.jpg">

but replace image.jpg with a url to the image :)

Link:https://replit.com/talk/ask/how-to-add-image-in-html/6999

LeoXu2 (41)

@ChUnGuSbOy he's asking how to download on click not how to set an image

Coder100 (18187)

You can't actually install the image due to a replit bug.

Click this button instead to open it to a new page to install it!

19ecal (232)

@Coder100 yeah I did have it open in a new tab but I actually just inspected it I will try actually putting it in the source of the page

LeoXu2 (41)

its probably because you have to open it in a new tab or something

LeoXu2 (41)

(cuz the replit preview thing in the code editor is an iframe i think)

[deleted]

@LeoXu2 you idiot

LeoXu2 (41)

o right it no work

[deleted]

@LeoXu2 sorry i thought he wants to insert a image