Download file from web application
Hi,
I am creating a web application using ASP.NET and C#.
However the download is not working. Below is the code used:
- //aspx page
<input type= "image" id="ImgDownload" src="Imagesrc" />
- // javascript file
$(document).ready(function () {
$('#ImgDownload').click(function () {
FetchURL();
- return false; // called to ensure there is no postback
- });
});
- function FetchURL(){
var url = file full URL;
- downloadURL(url);
}
- function downloadURL(url) {
var hiddenIFrameID = 'hiddenDownloader',
iframe = document.getElementById(hiddenIFrameID);
if (iframe === null) {
iframe = document.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
document.body.appendChild(iframe);
}
iframe.src = url;
};
The downloadURL function was taken from stackoverflow forum, in which the users had marked the code as answer. However,I am not able to use it correctly.
How to download file using jQuery?
Thanks