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.
-
Is.. this really hardly possible? Kind of interesting. – ChaseMoskal Mar 12 '14 at 00:49
-
You'll have to use something that can represent binary data, like a blob/file/typed array not a string – Musa Mar 12 '14 at 01:04
2 Answers
I use zipjs to handle zip files. A simple library that can handle reading and writing zip files.

- 1,045
- 15
- 34
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.

- 2,980
- 4
- 20
- 27
-
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