PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

APP端压缩上传,与PHP端解压实现

原创
2016-06-23 13:08:24 636浏览

一、android与php的交互

java

String body = "Lorem ipsum shizzle ma nizle";   URL url = new URL("http://some.url/file.php?id=" + uid);   URLConnection conn = url.openConnection();   conn.setDoOutput(true);   conn.setRequestProperty("Content-encoding", "deflate");   conn.setRequestProperty("Content-type", "application/octet-stream");   DeflaterOutputStream dos = new DeflaterOutputStream(conn.getOutputStream());   dos.write(body.getBytes());   dos.flush();   dos.close();

php

$content = http_get_request_body();$uncontent = gzuncompress($content);

二、ios与php的交互

php接收gzip压缩

gzdecode(base64_decode($json));//ios gzip uncompress

php接收zlib压缩

gzuncompress(base64_decode($json));//ios zlib uncompress


声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。