Gets the mime type associated with the format.
public getMimeType ( string $format ) : string | ||
$format | string | The format |
return | string | The associated mime type (null if not found) |
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $filename = 'image.jpg'; $mime = $request->getMimeType($filename); // returns "image/jpeg"
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $content = file_get_contents('file.pdf'); $mime = $request->getMimeTypeFromContent($content); // returns "application/pdf"Package library: Symfony HttpFoundation Note: The getMimeType method uses the MIME types defined in the mime.types file, which is located in the HttpFoundation component's Resources/config directory. If you need to use custom MIME types, you can add them to this file or create your own MIME types file and load it using the MimeTypes extension.
public getMimeType ( string $format ) : string | ||
$format | string | The format |
return | string | The associated mime type (null if not found) |