I have the following code:
$filecheck = basename($_FILES[\'imagefile\'][\'name\']);
$ext = substr($filecheck, strrpos($filecheck, \'.\') + 1);
if (($ext
You need two things:
Make your extension check case insensitive:
if($strtolower($ext == "jpg")){
// do your stuff
}
Check if the file actually contains an image. An easy way to do this is fileinfo:
$finfo = finfo_open(FILEINFO_MIME_TYPE);
echo finfo_file($finfo, $filename);
$finfo_close($finfo);
An alternative way of checking if a file is really an image is loading in an image library like gd. If your file can successfully be loaded, it is an image.
Keep in mind that jpeg images can have either the .jpg or the .jpeg extension.