当我尝试将输出作为给定图像this is the output
时,我编写了一个代码来获取条形码<?php
$ch = curl_init("https://chart.googleapis.com/chart?
chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
?>
答案 0 :(得分:0)
在将任何字符发送到浏览器之前,您必须发送PNG标头:
header('Content-Type: image/png');
如果你想强制下载图片,请使用以下代码:
header('Content-Disposition: Attachment;filename=imagename.png');
header('Content-type: image/png');
答案 1 :(得分:0)
检查标题类型:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: image/jpeg"));