Link to home
Start Free TrialLog in
Avatar of GiantMatrix
GiantMatrix

asked on

File type

Hi all,

How I can get file type from a file path (ex. C:\folder\image.gif) when someone is trying to "Upload" an image on my server.

I need to make sure that the file is either (JPEG OR JPG OR GIF).

So can someone please provide me with any sample code that can help me verify the uploaded image type in PHP

I get the file path and save it in a var called $imagepath

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of sajuks
sajuks

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
There is a special variable $_FILES['userfile']['type'] wich will read 'image/something...' while the uploaded file is an image.
Try it. Read more at http://pl.php.net/manual/en/features.file-upload.php