我试图获取MIME类型的配置文件图片格式为user_id.jpg或gif或png,我尝试过使用此代码,但它不起作用。获取MIME类型的文件
function detectFileMimeType($filename='')
{
$filename = escapeshellcmd($filename);
$command = "file -b --mime-type -m /usr/share/misc/magic {$filename}";
$mimeType = shell_exec($command);
return trim($mimeType);
}
function get_avatar($image, $user_id, $account)
{
$imgurl ="http://mypage/files/pictures/picture-" . ($user_id, $mimeType) . ".jpg";
if (!is_imgurl_good($imgurl)) {
$imgurl = "http://mypage/sites/all/themes/simple_custom/user.png";
}
return $imgurl;
}
您是否考虑过[为此设计的功能](http://php.net/manual/en/ref.fileinfo.php)? –
我从您提供的页面中获取了该代码。 – user123
您从已弃用的'mime_content_type()'页面中找到它。 –