public function File::getMimeType

Returns the mime type of the file.

The mime type is guessed using the functions finfo(), mime_content_type() and the system binary "file" (in this order), depending on which of those is available on the current operating system.

@api

Return value

string|null The guessed mime type (i.e. "application/pdf")

1 call to File::getMimeType()
File::guessExtension in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php
Returns the extension based on the mime type.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php, line 75

Class

File
A file in the file system.

Namespace

Symfony\Component\HttpFoundation\File

Code

public function getMimeType() {
  $guesser = MimeTypeGuesser::getInstance();
  return $guesser
    ->guess($this
    ->getPathname());
}