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!

3
  • 3
    How did that compressed text file makes its way into your JavaScript? Commented Aug 29, 2012 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 ) { /* … */ } } ); Commented Aug 29, 2012 at 10:48
  • Thanks! Yes, AJAX was part of the solution! Commented Aug 31, 2012 at 22:09

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for this link! It was realy helpgul to understand the solution.
Sorry, I tried, but I have not enough reputation to upvote your post. Thank you for posting it!
0

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

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.