猿问

服务端图片转Base64问题

<?php

$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1'); 
$str = json_decode($str,true);
$imgurl = 'http://cn.bing.com'.$str['images'][0]['url'];    //得到的图片url


//现在需要把图片转为Base64返回给用户
ITMISS
浏览 450回答 2
2回答

慕工程0101907

echo 'data:image/jpeg;base64,'.base64_encode(file_get_contents($imgurl));
随时随地看视频慕课网APP
我要回答