How can i download image from the url and save it to a local directory using javascript?

时间:2016-04-07 10:25:16

标签: javascript html image web

I have and thumbnail image url which i want to download and save to the local directory. How can I do it in javascript?

1 个答案:

答案 0 :(得分:1)

As the commenter mentioned, you can use the download attribute. However, this is very new and won't work in older browsers.

Other than that, you can't do this purely through JavaScript. This is because the headers needed to force the download are set on the server, via something like PHP. See this answer.

Whatever you do, you will need the user to agree to the download in the first place, but I assume you're aware of that.

相关问题