0

my sample code is <a href="@Html.ActualLink(attachment)" target="_blank" class="icon-download-alt pull-right"></a>. @Html.ActualLink(attachment) will have URL something like https://s3.amazonaws.com/79614248baeb/tree-736885-640-3929268565.jpg. Now this image file is opening in browser but what my requirement is, I need to download this image by clicking on an icon.

I can able to download all other file formats except image formats.

Depi
  • 17
  • 1
  • 2
  • 8
  • Right click in the browser and select "save image as" (or whatever similar option your browser of choice has) to save image... What exactly you trying to achieve programmatically so? (obviously you can't change how browser renders images from C# code as no code of yours is involved in that download.... so I guess you looking for some JavaScript help to achieve something...) – Alexei Levenkov Jul 20 '21 at 06:51

1 Answers1

0

Did you check other questions like Force browser to download image files on click? You should try to use download attribute on your <a> tag, but be careful, because it is not fully supported on all browsers https://caniuse.com/download

HC1122
  • 404
  • 1
  • 6
  • 19
  • I have already tried all answers in that like. I'm getting CORS origin error or else image is opening in browser but I need to download the image. – Depi Jul 20 '21 at 10:04