简体   繁体   English

如何在JavaScript中解压缩php的gzcompress?

[英]How to uncompress php's gzcompress in javascript?

I am making an android app and a website that downloads info from a php script. 我正在制作一个android应用程序和一个网站,该网站从php脚本下载信息。 The php script compresses the data using gzcompress($dat, 9); php脚本使用gzcompress($dat, 9);压缩数据gzcompress($dat, 9); .

I know how to uncompressed it in android, but how do you do it in javascript? 我知道如何在android中解压缩它,但是如何在javascript中做呢?

In this post: Compress data in php and uncompress in javascript 在这篇文章中: 在php中压缩数据并在javascript中解压缩

sstringer mentions you can put a special header when using php's gzencode so jquery can automatically uncompress it. sstringer提到在使用php的gzencode时可以放置一个特殊的标头,以便jquery可以自动将其解压缩。 Is there a way for the way I am doing it? 有没有办法做我的事情?

Thanks 谢谢

I looked into this myself once. 我曾经亲自调查过一次。 I decided to go to the ajax route and then redirect. 我决定去Ajax路由,然后重定向。

If you know where the file is being stored on the server you could post that to a php script which decompresses it and saves the file somewhere. 如果您知道文件在服务器上的存储位置,则可以将其发布到php脚本中,该脚本将其解压缩并将文件保存在某处。 Next, return this in the ajax response and then just redirect the user to the saved, decompressed file. 接下来,在ajax响应中返回此值,然后将用户重定向到已保存的解压缩文件。

There is a project on GitHub: https://github.com/gcanu/gzip.js GitHub上有一个项目: https : //github.com/gcanu/gzip.js

That might be what you are looking for. 那可能就是您要寻找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM