Link to home
Start Free TrialLog in
Avatar of Pedro Chagas
Pedro ChagasFlag for Portugal

asked on

Get image resolution when upload image

Hi, I create a control panel for my client change some parts of his site, and one thing he can do, is upload image.
But is not all images, just images that width < height.
I need help to know how I check the resolution of image, before I safe in respective folder.
I know get 3 things of each image, name, size in bytes, and the type:
=============
$filename = $_FILES['uploadfile']['name'];
        $filesize =  $_FILES['uploadfile']['size'];
            $filetype =  $_FILES['uploadfile']['type'];
===================
I need to know because if height < width the script don't continue.....

Have a way to know the resolution of image before I save the image in folder and in data base?

Regards,
JC
Avatar of Michael701
Michael701
Flag of United States of America image

you can use
getimagesize($_FILES['uploadfile']['name']);

more info at
http://us2.php.net/manual/en/function.getimagesize.php
Avatar of Pedro Chagas

ASKER

I use getimagesize like Michael701 said, but I get this warning:
Warning: getimagesize(PA273896.JPG) [function.getimagesize]: failed to open stream: No such file or directory in /home/luis/public_html/pre/painel_controle/painel_nivel1_imagem_upload.php on line 69

How I resolve this problem?
ASKER CERTIFIED SOLUTION
Avatar of Michael701
Michael701
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just change "$_FILES['userfile']['tmp_name']" to "$_FILES['uploadfile']['tmp_name']"