FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

How do i do this using PHP

 


avk
Here is my question

I have a text box thru which people can upload images.. but the main problem is that how does the script make it sure that the file selected is a image or not.

Is there any kind of function for such kind of activity.

Reply
muggle
You might take a look at this page
http://ca.php.net/features.file-upload
they are some examples related to your question as long as a discussion how reliable can be such kind of verification.
alalex
there is a function which i forgot, but you can search for it that takes whatever it is after a dot, and then you can compare that and see if it is gif, jpeg... or any other image format...
Kaneda
Probably the most reliable way is to use getimagesize, since it doesn't base itself on file extension (which can be changed):

Code:
$info = getimagesize($filename)


$info is FALSE, if the file is not a (recognized) image. Since it recognizes many types of images, you should then check $info[2] to get the actual image type, which is returned as a number - 1 = GIF, 2 = JPEG, 3 = PNG. Those are the common www types. For more (like SWF, PSD etc.), look at...

http://www.php.net/manual/en/function.getimagesize.php

Also has all the other info, of course Wink
alalex
cool
thanks
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.