I am wondering how to download all images , based on the URL in an array. I have an array like such for example
['https://url/image1.jpg', 'https://url/image2.jpg']
I have introduced a piece of code below to create a link and simulate a click and download the item. But the problem is it always redirects to another page instead of downloading the file , and it also seems to happen only on the first image not both ?
selectedItems.forEach(function (item) {
var link = document.createElement('a');
link.href = item.url;
link.download = item.description;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
Does anyone have a better idea ?