Javascript 如何将图像从页面保存到文件夹

Javascript 如何将图像从页面保存到文件夹,javascript,jquery,html,Javascript,Jquery,Html,我的index.html页面中有一个图像。我希望javascript或jquery通过单击按钮在我的a文件夹中自动下载此图像 <!DOCTYPE HTML> <html> <head> <title>save image from a page</title> </head> <body> <img src="car.jpg"/> <button>save Im

我的index.html页面中有一个图像。我希望javascript或jquery通过单击按钮在我的a文件夹中自动下载此图像

<!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>

从页面保存图像
将图像保存在我的文件夹中
$(“按钮”)。单击(函数()
{
//将图像从index.html下载到我的文件夹(saveImage)
});

我尝试了以下内容,并用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>

从页面保存图像
将图像保存在我的文件夹中
$(“按钮”)。单击(函数()
{
$('a')[0]。单击();
});

您熟悉php吗?你可以用php很容易地做到这一点。Abdush Samad Miah:是的,我熟悉php。那么你能告诉我怎么做吗?如果你没有下载jquery库,请添加这个