[英]how to save an image from a page to a folder
我的index.html页面中有一张图片。 我希望javascript或jquery通过单击按钮自动将其下载到我的文件夹中。
<!DOCTYPE HTML>
<html>
<head>
<title>save image from a page</title>
</head>
<body>
<img src="car.jpg"/>
<button>save Image in my folder</button>
<!-- the name of the folder is : (saveImage) : and it is in the same
place with my index.html-->
<script src="jquery-1.11.3.min.js"></script>
<script>
$("button").click(function()
{
// download image from the index.html to my folder (saveImage)
});
</script>
</body>
</html>
我尝试跟随并用Firefox和Chrome检查了它。 在两个浏览器上都能正常工作。 在链接中使用了HTML5“下载”属性。
<!DOCTYPE HTML>
<html>
<head>
<title>save image from a page</title>
</head>
<body>
<a style="display:none;" href="car.png" download>save Image in my folder </a>
<img src="car.png"/>
<!-- the name of the folder is : (saveImage) : and it is in the same
place with my index.html-->
<button>save Image in my folder</button>
<script src="jquery-1.11.3.min.js"></script>
<script>
$("button").click(function()
{
$('a')[0].click();
});
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.