I have and thumbnail image url which i want to download and save to the local directory. How can I do it in javascript?
答案 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.