2

How do I parse zip file string. I looked for hours I couldn't find an easy to do it. All the examples I found didn't make much sense.

Adam Zuckerman
  • 1,625
  • 1
  • 14
  • 20
user3167666
  • 124
  • 1
  • 6

2 Answers2

2

I use zipjs to handle zip files. A simple library that can handle reading and writing zip files.

shortspider
  • 957
  • 13
  • 29
0

BE MORE CLEAR NEXT TIME. I think this answer is what you need to hear.

A zip file can not be parsed with simple JavaScript. There is simply no native function that can ope ZIP files. There are certain libraries out there, but personally i have not found one that worked properly, and most use some kind of flash plugin to make it "work".

If you really want a zip file to be presented in Javascript, you will have to build its function with PHP. PHP can write to zip files, and read them: PHP ZIP. If you want to read the contents of a zip file, you would have to upload the file to the server (can be done with JS), then make the PHP return a JSON object with all the file_info of all the files inside the ZIP. And last but not least, JS should be able to acces another PHP page that retrieves a particular file, which can be done by reading the file and setting a mimetype before outputting its contents.

Nicky Smits
  • 2,406
  • 3
  • 17
  • 23
  • Downvoted because outdated. Modern JavaScript/Node seem to work pretty well, also PHP is not really required. – Tero Niemi Jan 04 '17 at 08:21