| Versions | |
|---|---|
| 5 – 6 | file_get_mimetype( |
| 7 | file_get_mimetype($uri, $mapping = NULL) |
Determine 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()
drupal/
<?php
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);
}
}
?>