The JavaScript library JSZip provides you with the ability to generate .zip files dynamically. This way you can send lots of data to a user in a convenient and bandwidth-saving way. With JavaScript becoming more and more powerful, and the amount of data handled by JavaScripts increasing every day, this is a great way to communicate with the user. Most users generally accept zip files from trusted sites – assuming that your users trust your site ;-)
It’s really easy to create a .zip file. Check out this sample code:
var zip = new JSZip(); zip.add("Hello.txt", "Hello World\n"); img = zip.folder("images"); img.add("smile.gif", imgData, {base64: true}); content = zip.generate(); location.href="data:application/zip;base64,"+content;
Creating zip files in the browser with JavaScript also removes some of the resource-consumption from your server.
Read more and download the library from JSZip.
No comments yet (leave a comment)