接口实现图片上传

1、客户端
file_get_contents($_FILES['img']['tmp_name']) //获取临时目录下的上传文件流,加密传给接口
 
2、接口处理端
$img = file_get_contents('php://input'); //获取最原始数据,所有的数据,必要时要进行截取
$path = './a.jpg';
$newFile = fopen($path,"w+"); //打开一个新文件
$res = fwrite($newFile,$img); //写入二进制流到文件
fclose($newFile); //关闭文件
原文地址:https://www.cnblogs.com/fwqblogs/p/6596272.html