gzinflate string compressed via JS

隐身守侯 提交于 2019-12-11 15:45:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!