js实现给定图片路径自动下载
目录
js实现图片自动下载
1.添加img标签
<img id='downImg' src='' style='display: none;' />
2.调用方法download
//图片路径
var src = './1.png';
//下载保存文件名
var imgname = 'testImg.jpg';
function download(src,imgname) {
$('#downImg').attr('src', src);
var img = $('#downImg').attr("src");
var alink = document.createElement("a");
alink.href = img;
alink.download = imgname;
alink.click();
}
Your place is valueble for me. Thanks!…