if you want to disallow only ".php" inside filename, you can check it with
strpos(strtolower($file_name),'.php')
or
EREGI("\.php",$file_name)
so,
if(!strpos(strtolower($file_name),'.php')){...allo w}
switch($realExtn)
{
case 'jpg':
case 'pdf':
case 'gif':
case 'png':
print "OK";
break;
default:
print "Bad";
}
This assumes that an extensions is only 3 characters. It also does not account for case (the extension JPG would be considered invalid). Here is a better way:
PHP Code:
function getExtension($str)
{
//get all of the characters following the last .
$ext = substr(strrchr($str, '.'), 1);
//make it safe to assume the extension is lower case
return strtolower($ext);
}