If I click that Download All I need to download all that image to my local system
<div>
<img src='image1.jpg'/>
<img src='image2.jpg'/>
<img src='image3.jpg'/>
<button> Download All </button>
</div>
Give me some solution for this
If I click that Download All I need to download all that image to my local system
<div>
<img src='image1.jpg'/>
<img src='image2.jpg'/>
<img src='image3.jpg'/>
<button> Download All </button>
</div>
Give me some solution for this
If you want to download without zipped them, you can use a javascript function like this to download one to one:
function downloadWithName(uri, name) {
function eventFire(el, etype){
if (el.fireEvent) {
(el.fireEvent('on' + etype));
} else {
var evObj = document.createEvent('MouseEvent');
evObj.initMouseEvent(etype, true, false,
window, 0,
0, 0, 0, 0,
false, false, false, false,
0, null);
el.dispatchEvent(evObj);
}
}
var link = document.createElement("a");
link.download = name;
link.href = uri;
eventFire(link, "click");
}
But, you need to make some changes in your code in order to allow to download all images with a single click. In your case, this code will run ;)
<div id="allImages">
<img src='image1.jpg' />
<img src='image2.jpg' />
<img src='image3.jpg' />
<button onclick="downloadAll()"> Download All </button>
</div>
<script>
function downloadAll(){
var div = document.getElementById("allImages");
console.log(div);
var images = div.getElementsByTagName("img");
console.log(images)
for(i=0; i<images.length ; i++){
console.log(images[i]);
downloadWithName(images[i].src,images[i].src);
}
}
function downloadWithName(uri, name) {
function eventFire(el, etype){
if (el.fireEvent) {
(el.fireEvent('on' + etype));
} else {
var evObj = document.createEvent('MouseEvent');
evObj.initMouseEvent(etype, true, false,
window, 0, 0, 0, 0, 0,
false, false, false, false,
0, null);
el.dispatchEvent(evObj);
}
}
var link = document.createElement("a");
link.download = name;
link.href = uri;
eventFire(link, "click");
}
</script>
As you can imagine, you can add more <img>
inside <div id="allImages">
and user will download all together.
HTTP does not support more than one file download at once.
There are two solutions:
You could use try scripts from this link for more options.
You can just left click on the website and select 'Save as..' (in Chrome) / 'save page as' (in Firefox). You will get all the images in that page in a folder. You do not have to use any scripts or any CLI.