简体   繁体   中英

How to download image file on anchor tag click without opening image in new tab?

I have following code as below in html file that uses asp.net. If the file is any other than the image file, it downloads automatically. But if the file is image, it opens it in tab and then we have to manually download it. How can I automate this process without prompting user to do so manually? And the values of URL and Filename come from database.

<a href="${URL}" download="${FileName}">
   <img 
      src="../Images/Download.png" 
      title="Click here to download the attachment." 
    />
</a>

要下载图像,请使用以下语法:

<a href="${Filename}" download="download">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM