My users are going to be uploading files with a .EXP extension. In ColdFusion on Windows 2003 I'm using getPageContext().getServletContext().getMimeType() to make sure that the file that they upload is of the correct mime-type, which will be text/plain. The issue I'm having is that no matter where I register the mime-type on the server, getPageContext().getServletContext().getMimeType() will return blank since it doesn't know about the .EXP file extension. What is the trick to get ColdFusion to see this file extension.
the MIME types supported are defined in your webserver, whether it's IIS, Apache or other. Apache MIME types can be configured in the mime.types files in the httpd/conf directory. The getMimeTypes() method communicates with the web server and returns the associated MIME type for the file.
http://chris.cfwebtools.com/index.cfm/2009/8/12/Securely-Serving-Files-via-CFContent
How about simply checking the request headers for the MIME type?
<cfset hrd = GetHttpRequestData()>
<cfdump var="#hrd#">
You'll get a struct that contains all data the client sent, including the content type of the uploaded file.
In any case, trusting the MIME type or the file extension the client sends you is dangerous, I would rather check the file with some other means (RegEx, for example, or a parser) to make sure it is what you expect.
FINALLY!!!!
In order for getPageContext().getServletContext().getMimeType() to recognize the new filetype, you must edit the file:
<ColdFusion-home>\runtime\lib\mime.types
In my case this file was located at:
C:\ColdFusion8\runtime\lib\mime.type
I opened file file and found this line:
text/plain asc txt
All I had to do was add my extension to the end like so:
text/plain asc txt exp
Then I restart the ColdFusion service and invoking getPageContext().getServletContext().getMimeType() return text/plain.