从URL获取图像宽度和高度不起作用


get image width and height from URL doesn't work

我想从url获取图像的宽度和高度,但它不起作用。上面写着

警告:getimagesize(https://scontent-b-sin.xx.fbcdn.net/hphotos-xpa1/t1.0-9/156922_131613136994348_1325598195_n.jpg) [function。[getimagesize]:打开流失败:D:'AppServ'www'test'test6.php第4行无效参数

PHP

    $url = "https://scontent-b-sin.xx.fbcdn.net/hphotos-xpa1/t1.0-9/156922_131613136994348_1325598195_n.jpg";
    list($width, $height, $type, $attr) = getimagesize($url);
  echo "Image width " . $width ."<br />";
  echo "Image height " . $height ."<br />";
  echo "Image type " . $type ."<br />";
  echo "Attribute " . $attr ."<br />";
?>

从我的电脑使用路径是工作。发生了什么事?谢谢你。

首先,使用file_exists函数来测试文件是否存在。此外,您还可以使用curl函数测试url。