Search code examples
javascriptphpgzippako

gzinflate string compressed via JS


I'm trying to compress a massive JS object on the client side via Pako and than get it back on the PHP-script.

JS code

const save_str = JSON.stringify(massive_object);
const gz_str = pako.gzip(save_str, { to: 'string' });
$.post('/', 
       {data:window.btoa(unescape(encodeURIComponent(gz_str)))}, 
       (data)=>{ console.log(data); },
       'json');

PHP code

$res = gzinflate(base64_decode($_POST['data']));

Should be quite straight-forward thing but I keep getting gzinflate(): data error. Already spent a few hours dancing around, still no result. Begging for help!


Solution

  • You want gzdecode(), not gzinflate().