File.getMimeType
$file.getMimeType() -> string
Description
Get the MIME type of the file.
This function uses PHP's FileInfo, which looks at key patterns in the file content. This is incrementally more secure than reading the file extension, which could be wrong or changed by an attacker to evade filtering.
For user-uploaded image files, use Input.getUploadedImage
to get a safely resized version of the file.
If you are serving other user-uploaded file types, a virus scanner is highly recommended.
file'files:/profileImage.png'.getMimeType() //= 'image/png' file'files:/taxForm.pdf'.getMimeType() //= 'application/pdf'