Determines an Internet Media Type or MIME type from a filename.
$uri: A string containing the URI, path, or filename.
$mapping: An optional map of extensions to their mimetypes, in the form:
The internet media type registered for the extension or application/octet-stream for unknown extensions.
file_default_mimetype_mapping()
function file_get_mimetype($uri, $mapping = NULL) {
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
return $wrapper
->getMimeType($uri, $mapping);
}
else {
// getMimeType() is not implementation specific, so we can directly
// call it without an instance.
return DrupalLocalStreamWrapper::getMimeType($uri, $mapping);
}
}