Download file from Url using HTML code in ASP.Net

paulrajmca
 
on Jul 28, 2021 04:05 AM
1141 Views

Hi Developers,

I need to download the image by the following html code. 

Html Code : 

<img id="imgIDproof" src="http://localhost:49730/KYCImages/IDProof_BSSPJ7416C_27072021101616AM.JPG" alt="IDProof" style="max-width: 200px; max-height: 200px; position: relative;" class="img-responsive img-thumbnail zoomify ui-draggable ui-draggable-handle">

Now i can't able to download properly, if anyone know how to download using the added code kindly suggest me to done this task

Regards,

Paul.S

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jul 28, 2021 04:07 AM

Hi paulrajmca,

For downloading you have to use html anchor tag instead of img tag.

<a href="http://localhost:49730/KYCImages/IDProof_BSSPJ7416C_27072021101616AM.JPG" download>Download</a>

 

paulrajmca
 
on Jul 28, 2021 04:13 AM

I have tried this Mr.Dharmendr ... Image is opening and displaying the same tab in browser but it is not downloading in my Downloads folder.

If possible kindly give any other suggestion.

 

Regards,

Paul.S

dharmendr
 
on Jul 28, 2021 04:19 AM

The download will not work in all browser. This is browser specific.

You need to use JavaScript or jQuery for this to work in all browser.

Refer below articles.

Download File in AJAX Response (Success) using jQuery

Automatically download PDF File using JavaScript