Search code examples
phpgetimagesize

getimagesize() not working for image upload


My attempt at getting the size of a newly uploaded image appears not to be working properly.

list($w, $h) = getimagesize($_FILES['image_field']);

echo 'width:'.$w;

outputs:

width:

How is this possible? I know for a fact the image (.jpg) is uploading fine because it's now on my server.


Solution

  • Use this code:

    list($w, $h) = getimagesize($_FILES["image_field"]["tmp_name"]);