I have some URL of files. I want to download all the files as a zip file using JavaScript. Is there any easy way to do it?
Some files needs to be downloaded to create a zip file, which are those?
This will get you started:
Download jsZip and load it in your html.
Then in your javascript:
var zip = new JSZip();
//skip this step if you don't want your files in a folder.
var folder = zip.folder("example");
folder.file("myfile1.txt", "HELLO WORLD IN 1ST FILE"); //requires filesaver.js
folder.file("myfile2.txt", "HELLO WORLD IN 2ND FILE");
//...so on until you have completed adding files
zip.generateAsync({type:"blob"})
.then(function(content) {
//see FileSaver.js
saveAs(content, "example.zip");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.