Heim >Backend-Entwicklung >PHP-Tutorial >php获取文件mimeType
/** *获取文件mimeType */ function getFileMimeType($fileName) { if (phpversion() >= '5.3.0') { $finfo = finfo_open(FILEINFO_MIME); $mimeType = finfo_file($finfo, $fileName); finfo_close($finfo); } else { $mimeType = mime_content_type($fileName); } return $mimeType; }