Download a picture OnClick

后端 未结 4 1211
感情败类
感情败类 2021-01-06 14:02

How do you actually download a picture when you click on it? Is there some kind of a javascript code to do just that? Here is how i show the image with pure HTML.

         


        
4条回答
  •  [愿得一人]
    2021-01-06 14:17

    Assuming by "download" you mean "Cause the user's browser to throw up the 'save or open' dialogue" — you can't.

    You could link to another URL offering the same file but with the Content-Disposition header set to attachment. The specifics of how you would provide such a resource at that URL would depend on the server side capabilities on offer to you.

提交回复
热议问题