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).

Note: Before the configured method for MIME detection is called, some hard-coded checks are applied. Use debug logging to find out if those checks cause false-positives. (For example, 1.15.3 may misdetect .doc-files from MS Word 2007 as ZIP files.)

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

Example (Linux): or shortly,