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();
}
GIS开发https://www.giserdqy.comGIS,WebGIS,ArcGIS,OpenLayers,Leaflet,Geoserver,PostGIS,BIM,空间大数据,GeoAI技术分享