FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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
Related topics
[tutor] How to protect images without htaccess using PHP
Using PHP
Includ Images using PHP.
How to start using PHP? Help!
Website Designing using PHP
how can i setup a page break for printer on html using php ?
Reading word documents using PHP?
I am trying to build a contact form using php and flash
Communicating between web pages
how to compress a file using php ?
Checking if ports are up using PHP
Hot to change "Reset Ownership" using php?
Using php to change content of a .txt
How to get the tree structure done using PHP
Making a expression calculator using PHP.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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