Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1272
  • Last Modified:

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
0
Pedro Chagas
Asked:
Pedro Chagas
  • 2
  • 2
1 Solution
 
Michael701Commented:
you can use
getimagesize($_FILES['uploadfile']['name']);

more info at
http://us2.php.net/manual/en/function.getimagesize.php
0
 
Pedro ChagasWebmasterAuthor Commented:
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?
0
 
Michael701Commented:
oops, try the temp name

$_FILES['userfile']['tmp_name']

I'm not sure if you'll need the temp path
0
 
Pedro ChagasWebmasterAuthor Commented:
Just change "$_FILES['userfile']['tmp_name']" to "$_FILES['uploadfile']['tmp_name']"
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now