Home >php教程 >php手册 >php 接收ios,Android传过来的图片

php 接收ios,Android传过来的图片

WBOY
WBOYOriginal
2016-06-07 11:38:281616browse

php 接收ios,Android传过来的图片
$content = file_get_contents("php://input");

$imgName = time();
$file_dir="images/".$imgName.".jpg";

if($fp = fopen($file_dir,'w')){

if(fwrite($fp,$content)){
fclose($fp);
}
}

thinkphp实例

public function saveAvatar(){

$filename = intval($_GET['id']).'.jpg';
$xmlstr = $GLOBALS['HTTP_RAW_POST_DATA'];

if(emptyempty($xmlstr)) {
$xmlstr = file_get_contents('php://input');
}

if(!$xmlstr){
exit( '没有接收到数据流.' );
}

$jpg = $xmlstr;//得到post过来的二进制原始数据

$file = fopen("./Public/Uploads/AVATAR/".$filename,"w");//打开文件准备写入
fwrite($file,$jpg);//写入
fclose($file);//关闭

}

交流QQ:243002768
IT精英交流群:36468081
招聘phper 前端
联系微信:wahha6616

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
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