You are here

public function File::getMimeType in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/http-foundation/File/File.php \Symfony\Component\HttpFoundation\File\File::getMimeType()
  2. 8 core/modules/file/src/Entity/File.php \Drupal\file\Entity\File::getMimeType()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/File/File.php \Symfony\Component\HttpFoundation\File\File::getMimeType()

Returns the mime type of the file.

The mime type is guessed using a MimeTypeGuesser instance, which uses finfo(), mime_content_type() and the system binary "file" (in this order), depending on which of those are available.

Return value

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

See also

MimeTypeGuesser

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

File

vendor/symfony/http-foundation/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());
}