Manual:$wgMimeDetectorCommand

Details
Sets an external mime detector program. The command must print only the mime type to standard output. The name of the file to process will be appended to the command given here. If not set or NULL, the PHP function  will be used if available (PHP >= 4.3.0).

See Manual:Mime type detection for details. See also Manual:Configuring file uploads.

Example (Linux):