Reputation: 150
I created a table filled with file names in a directory. Now i want to download this files from uploaded directory. I m getting multiple file names then parsing them to send them one by one.I menaged this with this code but it only downloads last file.
while (dowloadParts[i] != "")
{
window.location = "http://" + window.location.host + "/Uploads/" + dowloadParts[i];
}
What should i do to menage multiple file download.
Upvotes: 2
Views: 1596
Reputation: 150
I solved my problem with creating iframe for every single download file request. here is my code;
function downloadFile(filesForDownload) {
i = 0;
var downloadParts = filesForDownload.split(';');
while (downloadParts[i] != "") {
downloadURL("http://" + window.location.host + "/Uploads/" + downloadParts[i]);
i++;
}
}
var count = 0;
var downloadURL = function downloadURL(url) {
var hiddenIFrameID = 'hiddenDownloader' + count++;
var iframe = document.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
document.body.appendChild(iframe);
iframe.src = url;
}
Upvotes: 3