The finfo function is returning crazy mime types. Look the following code, what is going on?
At present, there seems to be a bug with finfo
https://bugs.php.net/bug.php?id=53035
it's got to do with the content of the actual mime database, as opposed to any erroneous logic.
What I'm doing (which may not be as useful for more rigourous situations) is hard code the correct mime types that I know I'll need so that the hard coding will simply need to be commented out for the next version of PHP. À la:
$info = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($info, $file_name);
$extension = pathinfo($file_name,PATHINFO_EXTENSION);
//there is a bug with finfo_file();
//https://bugs.php.net/bug.php?id=53035
//
// hard coding the correct mime types for presently needed file extensions
switch($extension){
case 'css':
$mime_type = 'text/css';
break;
case 'js':
$mime_type = 'application/javascript';
default:
break;
}