File.getMimeType
File.getMimeType($path) -> string
Description
Get the MIME type of the file.
The $path
is relative to the data/files
directory.
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.uploadedImage()
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.getMimeType('profileImage.png') //= 'image/png' File.getMimeType('taxForm.pdf') //= 'application/pdf'