[英]Download image to my web server using javascript
I want to download image from url say, www.someurl.com/images/a.jpg
to server on which my application is running. 我想从网址(例如
www.someurl.com/images/a.jpg
下载图像到运行我的应用程序的服务器。 Can I do this in javascript
or I have to make web service and call it? 我可以使用
javascript
做到这一点,还是必须提供网络服务并调用它?
You can. 您可以。 XMLHTTPRequest if you are using plain js or simply use jquery $.get()
XMLHTTPRequest如果您使用纯js或只是使用jquery $ .get()
If you're talking about downloading an image from an external website to your own server, not using the clients browser. 如果您要谈论的是将图像从外部网站下载到自己的服务器,而不是使用客户端浏览器。 Then you might want to check out node-wget , which allows you to very easily download a file from your node.js program:
然后,您可能需要检出node-wget ,它使您可以非常轻松地从node.js程序下载文件:
var wget = require('node-wget');
wget(url);
In javascript try using this one 在javascript中尝试使用这个
var a = $("<a>")
.attr("href", "www.someurl.com/images/a.jpg")
.attr("download", "img.png")
.appendTo("body");
a[0].click();
a.remove();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.