Debanjan Dhar
Debanjan Dhar

Reputation: 418

Something wrong with code

var image = new Image();
image.src = canvas.toDataURL("image/png");
var link = document.createElement('a');
link.href = image;
link.download = 'Download.png';
document.body.appendChild(link);
link.click();

When I use this script it returns me a download error

(File not found)

Why?

Upvotes: 3

Views: 54

Answers (1)

Phani
Phani

Reputation: 861

change

link.href = image;

to

link.href = image.src;

Upvotes: 3

Related Questions