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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools