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

WBOY
Release: 2016-06-23 13:08:24
Original
798 people have browsed it

一、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();
Copy after login

php

$content = http_get_request_body();$uncontent = gzuncompress($content);
Copy after login

二、ios与php的交互

php接收gzip压缩

gzdecode(base64_decode($json));//ios gzip uncompress
Copy after login

php接收zlib压缩

gzuncompress(base64_decode($json));//ios zlib uncompress
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!