Php 返回空页
我试图卷曲这个位置,每次都返回空页。我的代码是Php 返回空页,php,curl,Php,Curl,我试图卷曲这个位置,每次都返回空页。我的代码是 $image = 'http://island-alpaca.selfip.com:10202/SnapShotJPEG?Resolution=640x480&Quality=Standard'; $ch = curl_init(); curl_setopt($ch,CURLOPT_VERBOSE,true); curl_setopt($ch, CURLOPT_URL, $image); $store = cur
$image = 'http://island-alpaca.selfip.com:10202/SnapShotJPEG?Resolution=640x480&Quality=Standard';
$ch = curl_init();
curl_setopt($ch,CURLOPT_VERBOSE,true);
curl_setopt($ch, CURLOPT_URL, $image);
$store = curl_exec ($ch);
echo $store;
curl_close ($ch);
有人能告诉我遗漏了什么吗?试着补充一下
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
因此,代码将是:-
$image = 'http://island-alpaca.selfip.com:10202/SnapShotJPEG?Resolution=640x480&Quality=Standard';
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE,true);
curl_setopt($ch, CURLOPT_URL, $image);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$store = curl_exec ($ch);
curl_close ($ch);
header("Content-type: image/jpeg");
echo $store;
试着做:
...
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $image);
// Get binary data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$image = curl_exec($ch);
curl_close($ch);
// output to browser
header("Content-type: image/jpeg");
echo $image;
编辑:尝试将url设置为:
$image = 'http://island-alpaca.selfip.com:10202/SnapShotJPEG?Resolution='.urlencode('640x480&Quality=Standard');
为什么url中有空格?Sudhir给了你答案,你没有returntransfer+没有将页面标题更改为jpg。+1这是正确的答案!!如果没有标题和二进制设置,它将显示页面中的所有垃圾数据。对于OP,究竟为什么您希望使用CURL获取图像,为什么不使用
标记并在那里使用URL?实际上,php 5.1.3不需要二进制传输。From:“从PHP5.1.3开始,此选项无效:当使用CURLOPT_RETURNTRANSFER时,将始终返回原始输出。”尝试启用错误报告(1)时,是否有任何错误;