我是靠谱客的博主 爱撒娇花卷,这篇文章主要介绍php获取图片数据,服务器端php获取图片数据流,现在分享给大家,希望可以做个参考。

$base64 = file_get_contents("php://input"); //获取输入流

$base64 = json_decode($base64,1);

$data = $base64['base64'];

preg_match("/data:image/(.*);base64,/",$data,$res);

$ext = $res[1];

if(!in_array($ext,array("jpg","jpeg","png","gif"))){

echo json_encode(array("error"=>1));die;

}

$file = time().'.'.$ext;

$data = preg_replace("/data:image/(.*);base64,/","",$data);

if (file_put_contents($file,base64_decode($data))===false) {

echo json_encode(array("error"=>1));

}else{

echo json_encode(array("error"=>0));

}

最后

以上就是爱撒娇花卷最近收集整理的关于php获取图片数据,服务器端php获取图片数据流的全部内容,更多相关php获取图片数据内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(115)

评论列表共有 0 条评论

立即
投稿
返回
顶部