I have the following code:
$filecheck = basename($_FILES[\'imagefile\'][\'name\']);
$ext = substr($filecheck, strrpos($filecheck, \'.\') + 1);
if (($ext
take note that for Internet Explorer, they submit JPEG file's mime type as image/pjpeg - which is different from other browsers.
Here's a simple function to get your mime type against the file extension:
function mime2ext($mime){ // mime is like image/jpeg
$m = explode('/',$mime);
$mime = $m[count($m)-1]; // get the second part of the mime type
switch($mime){
case 'jpg':
case 'jpeg':
case 'pjpeg':
return 'jpg';
break;
case 'png':
return 'png';
break;
case 'gif':
return 'gif';
break;
}
return '';
}