1

I've managed to gzip my response from my server to my client, but now I also want to gzip the data send from the client to the server. I'm using zlib.js as follows:

var gzip = new Zlib.Gzip(dataUint8Array);
var compressed = gzip.compress();

Where the returned compressed is a Uint8 array. How do I send the data to the server, especially, how do I decode this in PHP? I tried using gzdecode in PHP to decode the array, but that didn't work. Then I tried to convert the compressed array in JS back to a string before sending it to the server, but gzdecode could also not decode that. Any suggestions?

goocreations
  • 2,938
  • 8
  • 37
  • 59

1 Answers1

0

Perhaps this answer will help.

https://stackoverflow.com/a/8896524/3585500

Force uncompression with the Accept-Encoding: deflate header.

Community
  • 1
  • 1
ourmandave
  • 1,505
  • 2
  • 15
  • 49
  • Looked at that and played around, but can't get it to work. Should I send a byte array or string to the server for this? – goocreations Aug 20 '15 at 11:34
  • If you're posting it back via ajax, try sending it as a blob. This answer uses FormData [link](http://stackoverflow.com/a/22621393/3585500) which is not supported in older browsers. The older way is to use an Iframe. – ourmandave Aug 20 '15 at 12:39