如何在PHP中获取上传图像的宽度和高度[重复]

This question already has an answer here:

Currently this is my code:

echo "Upload: " . $_FILES["file"]["name"] . "<br>";
          echo "Type: " . $_FILES["file"]["type"] . "<br>";
          echo "Size: " . ($_FILES["file"]["size"] / 1024) . " KB<br>";
          echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br>";

  move_uploaded_file($_FILES["file"]["tmp_name"],"images/" . $_FILES["file"]["name"]);
            echo "images/" . $_FILES["file"]["name"];
            $path="images/" . $_FILES["file"]["name"];
</div>
$image_info = getimagesize($_FILES["file"]["tmp_name"]);
$image_width = $image_info[0];
$image_height = $image_info[1];

You can refer to: http://www.php.net/manual/en/function.getimagesize.php for reference!

NOTE: Check the uploaded file to be image before using "getimagesize" otherwise you will get an error.

Try this :

list($width, $height, $type, $attr) = getimagesize($path);
echo "Width is : " . $width;
echo "Height is : " . $height;