Heim  >  Artikel  >  Backend-Entwicklung  >  APP端压缩上传,与PHP端解压实现

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

WBOY
WBOYOriginal
2016-06-23 13:08:24796Durchsuche

一、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


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn