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">

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 for more details. in the console
how do i do this



<img src="">

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


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)


@LeoXu2 you idiot

LeoXu2 (41)

o right it no work


@LeoXu2 sorry i thought he wants to insert a image