Get image resolution when upload image

Posted on 2009-02-10
Last Modified: 2012-05-06
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?

Question by:Pedro Chagas
    LVL 19

    Expert Comment

    you can use

    more info at
    LVL 3

    Author Comment

    by:Pedro Chagas
    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?
    LVL 19

    Accepted Solution

    oops, try the temp name


    I'm not sure if you'll need the temp path
    LVL 3

    Author Closing Comment

    by:Pedro Chagas
    Just change "$_FILES['userfile']['tmp_name']" to "$_FILES['uploadfile']['tmp_name']"

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now