Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The gzuncompress of php equivalent on javascript

I have a php file that do:

echo(gzcompress("TEST COMPRESS"));

and on javascript i do a request on php and i want a function that do the same of gzuncompress(data) for take the result = "TEST COMPRESS" again on client side.

EDIT: Thank you @aaronk6, zlib worked!

If someone ready this question, the zlib will works if the php is with gzencode(), gzcompress will not work.

like image 927
Matheus Benedet Avatar asked Dec 09 '25 14:12

Matheus Benedet


1 Answers

As @SLaks pointed out, this is might be pointless, however here’s an answer to your question.

Browsers do not have a uncompress method that is accessible from JavaScript, so there’s no equivalent. When you want to decompress gzipped data in JavaScript, you will need to use a JavaScript implementation of the gzip algorithm.

There’s zlib.js which seems to be capable of doing this.

like image 66
aaronk6 Avatar answered Dec 11 '25 05:12

aaronk6



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!