how to determine the correct extension file is uploaded???

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2005
vishal
 
Posts: n/a
Default how to determine the correct extension file is uploaded???

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

Reply With Quote
  #2 (permalink)  
Old 04-16-2005
rovisoft
 
Posts: n/a
Default re:how to determine the correct extension file is uploaded???

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
Reply With Quote
  #3 (permalink)  
Old 04-16-2005
Chung Leong
 
Posts: n/a
Default Re: how to determine the correct extension file is uploaded???

http://www.php.net/getimagesize/

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:26 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0