I have a base64-encoded image from the server for which I want to force the download through JavaScript. Is is possible?
If you want to download it using JavaScript (without any back-end) use:
window.location.href = 'data:application/octet-stream;base64,' + img;
where img
is your base64 encoded image.
If you want to allow the user to specify a file name, use the download
attribute of the a
tag:
Download