Hello Reader's!
If you want to make your file download by execution of JS then you can use the code below:-
var a = document.createElement('a');
a.href = "/favicon.png"; //make the link of image
a.download = "favicon.png";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
Or you can use same function but another way:-
var a = $("<a>").attr("href", "http://i.stack.imgur.com/L8rHf.png").attr("download", "img.png").appendTo("body");
a[0].click();
a.remove();
In both cases, your file will download.
0 Comment(s)