Gets the MIME type for the file path/file object you have specified.
fileGetMimeType(file, strict)
→ returns string
true
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.
<cfscript>
mimeTypes = '';
mimeTypes = listAppend(mimeTypes, fileGetMimeType(expandPath('/folder1/test.pdf')));
mimeTypes = listAppend(mimeTypes, fileGetMimeType(expandPath('/folder1/test.pdf'),false));
mimeTypes = listAppend(mimeTypes, fileGetMimeType(expandPath('/folder1/test.txt')));
mimeTypes = listAppend(mimeTypes, fileGetMimeType(expandPath('/folder1/test.txt'),false));
writeOutput(mimeTypes);
</cfscript>
Expected Result: application/pdf,application/pdf,text/plain,text/plain
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.