function File::guessExtension
Returns the extension based on the mime type.
If the mime type is unknown, returns null.
This method uses the mime type as guessed by getMimeType() to guess the file extension.
See also
getMimeType()
File
-
vendor/
symfony/ http-foundation/ File/ File.php, line 53
Class
- File
- A file in the file system.
Namespace
Symfony\Component\HttpFoundation\FileCode
public function guessExtension() : ?string {
if (!class_exists(MimeTypes::class)) {
throw new \LogicException('You cannot guess the extension as the Mime component is not installed. Try running "composer require symfony/mime".');
}
return MimeTypes::getDefault()->getExtensions($this->getMimeType())[0] ?? null;
}