FileGetMimeType
Gets the MIME type for the file path/file object you have specified.
Method Signature
Arguments
Argument
Type
Required
Description
Default
file
string
true
The file path or file object to get the MIME type for.
strict
boolean
false
If true, throws an exception if the file does not exist or is empty. If false, returns "application/octet-stream" for non-existent or empty files.
true
Examples
Two PDFs and two text files with and without strict mode
Assume that you have a file named test.pdf in temp directory and test.txt in the same folder, and you want to check the MIME type. Here test.txt is a copy of test.pdf with extension renamed to txt.
Result: application/pdf,application/pdf,text/plain,text/plain
Additional Examples
Related
Last updated
Was this helpful?