问题
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!
回答1:
You want gzdecode()
, not gzinflate()
.
来源:https://stackoverflow.com/questions/52952929/gzinflate-string-compressed-via-js