4

I found a javascript plugin that could generate zip files, its called jszip.

I tried it, but I think it could only generate the files that will be compiled in a zip file.

What I want is to be able to add existing files to the zip file that it will generate. Is it possible in JavaScript?

Emma
  • 27,428
  • 11
  • 44
  • 69
user225269
  • 10,743
  • 69
  • 174
  • 251

1 Answers1

5

Scroll down to the Documentation section on the page you linked to. It describes plainly how to add files to the zip file. For binary files you'll end up using base64, it looks like. For text files you can pass them straight in as strings. Of course you'll need access to the file data in order to add it to the zip file, which is easy enough if you're, say, retrieving said data in an Ajax request, but an uphill battle if you want the user to be able to zip files from his or her local storage.

Jordan Running
  • 102,619
  • 17
  • 182
  • 182