0

Possible Duplicate:
Unzip files using JavaScript

What should I do If I have a simple compressed text file (in a .zip/.rar/... file) and I want to read it into a String with JavaScript?

In other words if the content of my compressed test.txt file is "Hello world", then what should I do to copy this "Hello word" text into a String?

How to do this? Which compression format should I use (.zip/.rar/other)?

Thank you in advance!

Community
  • 1
  • 1
Fract
  • 315
  • 1
  • 3
  • 19
  • 3
    How did that compressed text file makes its way into your JavaScript? – Ja͢ck Aug 29 '12 at 10:46
  • You could load any document from JS via AJAX methods, but I don't know how to decompress it. e.g. `jQuery.ajax( { url: 'THE_FILE_NAME', complete: function( jqXHR, status ) { /* … */ } } );` – feeela Aug 29 '12 at 10:48
  • Thanks! Yes, AJAX was part of the solution! – Fract Aug 31 '12 at 22:09

2 Answers2

1

Assuming you succeeded in loading the compressed file to a javascript variable (through AJAX?), follow this similar question in order to unzip it:

Unzipping files

Community
  • 1
  • 1
Lior
  • 2,181
  • 1
  • 13
  • 14
0

Try use zip.js: http://gildas-lormeau.github.com/zip.js/

Example: http://gildas-lormeau.github.com/zip.js/demos/demo2.html

defuz
  • 24,215
  • 8
  • 36
  • 59