CFLib.org – Common Function Library Project

getFileMimeType(filePath)

Last updated July 19, 2005

Version: 1 | Requires: ColdFusion MX | Library: FileSysLib

 
Rated 2 time(s). Average Rating: 4.5

Description:
Utilizes the getMimeType() method of the ServletContext object to determine the mime type of the specified file. Returns an empty string if the mime type of the file is unknown. The function takes one argument, the physical file path of the file.

Return Values:
Returns a string.

Example:

view plain print about
<cfoutput>
    #getFileMimeType("C:\Inetpub\wwwroot\cfdocs\htmldocs\images\babelfi2.jpg")#
</cfoutput>

Parameters:

Name Description Required
filePath The file to examine, Yes

Full UDF Source:

view plain print about
<!---
 Returns the mime type of the specified file.
 
 @param filePath      The file to examine, (Required)
 @return Returns a string. 
 @author Ben Rogers (ben@c4.net) 
 @version 1, July 19, 2005 
--->

<cffunction name="getFileMimeType" returntype="string" output="no">
    
    <cfargument name="filePath" type="string" required="yes">
    
    <cfreturn getPageContext().getServletContext().getMimeType(arguments.filePath)>
    
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson