[英]from canvas.toDataURL() to download the image
I'm trying to download the image from a canvas tag. 我正在尝试从canvas标签下载图像。 I get from var image = canvas.toDataURL()
base64, and thought that this could be used to create a <a>
tag, and adding inside the tag download = "image.png"
and href = img
and simulate a click. 我从var image = canvas.toDataURL()
base64获得,并认为这可用于创建<a>
标签,并在标签中添加download = "image.png"
和href = img
并模拟点击。 I've googled around, but didn't find quite what I was looking for. 我在Google周围搜索,但是找不到我想要的东西。
I found an answer actually to this question, lol. 我实际上找到了这个问题的答案,大声笑。
var link = document.createElement('a');
link.href = 'images.jpg';
link.download = 'Download.jpg';
document.body.appendChild(link);
link.click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.