我正在尝试从google API创建图像和QR码并将其插入到我的数据库中,稍后我将在我的网站上显示该图像。我有https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=123456这个网址,我想查看数据库中的图片。
$servername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "mydb";
$conn = mysqli_connect( $servername, $dbUsername, $dbPassword, $dbName);
if(!$conn)
{
die("Connection with db not succesful".mysqli_connect_error());
}
function getImage($url){
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$resource = curl_exec($ch);
curl_close ($ch);
return $resource;
}
$image=imagecreatefromstring(getImage("https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=123456"));