Getting mime in php

We have been using php fileinfo for a while and were not happy about how office 2007 files were identified as .zip as mime type. Which is actually accurate they are zip archives. When serving those files back to users we had some users complain about file being identified as corrupt.

If you can compile your own magic.mime (file -C -m ) or if you have access to magic file you can edit it too.

My case I used file from cli.

$file_type = shell_exec("file --mime-type {$file['tmp_name']}");
$file['type'] = trim(end(explode(':', $file_type)));