Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get image height and width PHP

Hello I need to get the height and width on the fly of an uploaded image.

This is the PHP function I am using, but it does not return anything for the width and height..

Could you please help me?

list($width, $height, $type, $attr) = getimagesize($_FILES["Artwork"]);
$min_width = "1000";
$min_height = "1000";
if ((($_FILES["Artwork"]["type"] == "image/gif") || ($_FILES["Artwork"]["type"] == "image/jpeg") || ($_FILES["Artwork"]["type"] == "image/jpg")
|| ($_FILES["Artwork"]["type"] == "image/pjpeg")) && ($_FILES["Artwork"]["size"] < 20000000) && ($width > $min_width) && ($height > $min_height) && ($width == $height))
  {


  if ($_FILES["Artwork"]["error"] > 0)
    {
    //echo "Return Code: " . $_FILES["Artwork"]["error"] . "<br />";


   }else{
      move_uploaded_file($_FILES["Artwork"]["tmp_name"],
      $path_image . $imageName);
      header("Location: http://pitchmystuff.co.uk/m/digidist/tracks/".$idAlbum."");
      }



   }else{
    //echo "invalid file";

    echo '<script>
    alert("There was an error uploading your coverart file. Please check the requirements and try again.'.$width.$height.'");
    document.location ="http://pitchmystuff.co.uk/m/digidist/albums/";
    </script>';


    }
like image 360
DiegoP. Avatar asked Sep 27 '11 14:09

DiegoP.


2 Answers

Should be

list($width, $height, $type, $attr) = getimagesize($_FILES["Artwork"]['tmp_name']);

See http://www.php.net/manual/en/features.file-upload.post-method.php

like image 104
Phil Avatar answered Oct 12 '22 16:10

Phil


<?php

$imagedetails = getimagesize($_FILES['Artwork']['tmp_name']);
$width = $imagedetails[0];
$height = $imagedetails[1];

?>
like image 40
Ravi Patel Avatar answered Oct 12 '22 16:10

Ravi Patel