The correct little correction:
exec will return the mime with a newline at the end, the trim() should be called with the result of exec, not the other way around.
<?php
if ( ! function_exists ( 'mime_content_type ' ) )
{
function mime_content_type ( $f )
{
return trim ( exec ('file -bi ' . escapeshellarg ( $f ) ) ) ;
}
}
?>