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

时间:2014-07-11 10:35:48

标签: php

我想从网址获取图片的宽度和高度,但它不起作用。它说

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

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 />";

?>

使用计算机中的路径是可行的。发生了什么事?谢谢。

1 个答案:

答案 0 :(得分:-2)

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