PHP通过api上传图片

参考:接口实现图片上传

 

提交端:

    $url="localhost:805/rdyc/123.jpg";
    $img=file_get_contents($url);

    $img_api="http://localhost:805/hello.php";
    $img_api_url=$img_api.'?'.http_build_query(array('img'=>$img));

    file_get_contents($img_api_url);

接收端:

$img=$_GET['img'];
$file="./a.jpg";
file_put_contents($file,$img);

 

posted @ 2018-03-12 11:18  jiafeng  阅读(902)  评论(0编辑  收藏  举报