Can't Download Folder With Jszip
I am wanting to zip and download a folder. I can't seem to find out how. JSZip seems to only download files. I don't want to have to use PHP. Last thing, I want it to download with
Solution 1:
Just keep calling zip.file(). Look at the example from their http://stuk.github.io/jszip/
for example like below :
var zip = new JSZip();
// Add a text file with the contents "Hello World\n"
zip.file("Hello.txt", "Hello World\n");
// Add a another text file with the contents "Goodbye, cruel world\n"
zip.file("Goodbye.txt", "Goodbye, cruel world\n");
// Add a folder named "images"var img = zip.folder("images");
// Add a file named "smile.gif" to that folder, from some Base64 data
img.file("smile.gif", imgData, {base64: true});
var content = zip.generate();
location.href="data:application/zip;base64,"+content;
The important thing is to understand the code you've written - learn what each line does. If you do this, you'd realize that you just need to call zip.file() again to add another file.
Baca Juga
- Need To Zip The Selected File From Client Machine When Uploading (using Jszip) In .net Web App. The Zipped File Should Be Uploaded To Server Location
- Temporarily Unzip A File To View Contents Within A Browser
- Is There A Way To Default Or Suggest A Folder Structure On A Direct Download Without Using A Zip File?
Post a Comment for "Can't Download Folder With Jszip"