This is a discussion on how to determine the correct extension file is uploaded??? within the PHP Language forums, part of the PHP Programming Forums category; i am allowing user to add file upload to server and the suer can put only those files which display ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
i am allowing user to add file upload to server and the suer can put
only those files which display some image i.e. jpg or gif or other photo file. so how can i check that the user has selected correct type of file to upload thxs for help in advance |
|
|||
|
This is a small function that will return the file extension, all you
have to do is to compare it with what you allow: function get_ext($filename) { $file=explode(".",$filename); return $file; } Or you can check the file type, if it's image/gif, image/jpeg or image/png! You can do that with this function, where $f is the full path to the file if (!function_exists('mime_content_type')) { function mime_content_type($f) { $f = escapeshellarg($f); return trim( `file -bi $f` ); } } Ovidiu:) DevPlug.com Forum |
|
|||
|
|