Mario
Mario

Reputation: 2021

Download image which is src attribute (base64)

through AJAX I receive a image in base64 which I adjunct to the src attribute of a img tag.

I want to offer an option to download that image, is it possible to take the data of the src attribute and download it? This is because I cannot download the image again from the server.

Thank you.

Upvotes: 3

Views: 1440

Answers (1)

Phil
Phil

Reputation: 164760

Just set the window.location to the encoded URI (or open a popup window), eg

window.location.href = 'data:image/png;base64,iVBORw0KGgo....

Upvotes: 3

Related Questions