note 116792 deleted from function.mime-content-type by sobak
| From: | sobak@php.net | Date: | Sat, 07 Mar 2015 07:56:35 +0000 |
| Subject: | note 116792 deleted from function.mime-content-type by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-201883@lists.php.net to get a copy of this message | ||
Note Submitter: Bond Akinmade
----
using
<?php
function detectFileMimeType($filename='')
{
$filename = escapeshellcmd($filename);
$command = "file -b --mime-type -m /usr/share/misc/magic {$filename}";
$mimeType = shell_exec($command);
return trim($mimeType);
}
?>
should work on most shared linux hosts without errors. Also, it works on Windows hosts with git
installed.