我正尝试使用file_get_contents PHP函数下载图像。file_get_contents不适用于某些图像
它通过GET接收urlencode(url)并返回内容。 这是代码:
<?php
$url=($_GET["url"]);
$url2 = ("http://www.liberoquotidiano.it/resizer.jsp?w=500&h=-1&maximize=true&img=upload/cut1372677360319.jpg&filetype=image.jpg");
echo "<br>Url 1 is via GET <br> Url2 is a variable instantiated in the script and its value is manually inserted.";
echo "<br>file_get_contents Url2 work, but with url1 not,althought the url content is the same. ";
echo "<br>1.url= ".$url;
echo "<br>2.url= ".$url2;
$r=strcmp($url2,$url);
if($r==0){
echo "correct";
}else{
echo "<br><br>string compare with url and url2 return ".$r;
}
echo "<br><br>launch: file_get_contents(url) => ";
$image_data = file_get_contents($url);
echo $image_data;
?>
url和URL2相同,但PHP代码的strcmp返回1,而不是0 ...我不明白为什么。 如果我启动
file_get_contents($url);
它不工作,我还没有返回的任何值。 如果我启动
file_get_contents($url2);
它正常工作。
好奇的是,url和url2包含相同的值,但结果不同。
可能是什么问题? 非常感谢。
有了,我已经发布我发了仅仅用这个GET头值的URL(所以我认为它不是这样的,你提的问题): URL = HTTP%3A%2F%2Fwww.liberoquotidiano。它%2Fresizer.jsp%3Fw%3D500%26amp%3Bh%3D-1%26amp%3Bmaximize%3Dtrue%26amp%3Bimg%3Dupload%2Fcut1366795446185.jpg%26amp%3Bfiletype%3Dimage.jpg – michele
我没有看到任何关于html在获取参数 – michele