Home  >  Article  >  Backend Development  >  在线等,周六周天都在加班弄这个问题,怎样获取上传图片的长度宽度

在线等,周六周天都在加班弄这个问题,怎样获取上传图片的长度宽度

WBOY
WBOYOriginal
2016-06-23 13:45:44996browse

怎样获取上传图片的长度和宽度
list( $width ,  $height ,  $type ,  $attr ) = getimagesize(' http://192.168.254.20/Public/images/0.jpg');
         echo $width;
         echo $height;
        echo $attr;


        $img = imagecreatefromjpeg("http://http://192.168.254.20/Public/images/0.jpg");
         echo  imagesx( $img );
     echo "imagesy( $img )";
        exit;
这两种方法都不行,没有输出任何数据。图片路径是对的,可以打开图片


回复讨论(解决方案)

第一种方法是可以的,怀疑你路径有问题。
list( $width ,  $height ,  $type ,  $attr ) = getimagesize('http://avatar.csdn.net/1/9/2/1_mengfk000.jpg');
print_r($width);echo "
";
print_r($height);echo "
";
print_r($attr);echo "
";

打开php的错误提示功能。

如果图片能打开,至少第二种是有输出的。第一个是因为 getimagesize( ' http://192.168.254.20/Public/images/0.jpg'); 路径前面有空格。

print_r(getimagesize('http://avatar.csdn.net/1/9/2/1_mengfk000.jpg'));
Array
(
    [0] => 150
    [1] => 150
    [2] => 2
    [3] => width="150" height="150"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn