我使用此代码在php中获取图像大小,并且它正在为我完美工作。通过CURL在PHP中获取图像大小
$img = get_headers("http://ultoo.com/img_single.php", 1);
$size = $img["Content-Length"];
echo $size;
但是如何通过CURL来获取? 我试过但没有效果。
$url = 'http://ultoo.com/img_single.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, "Content-Length");
//curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$filesize = $result["Content-Length"];
curl_close($ch);
echo $filesize;
它不重复,当我在给定的链接上使用给定的代码时,我在Result中得到-1 。 – user2424807