User Guide
GetFileFromPath 489
GetFileFromPath
Description
Extracts a filename from an absolute path.
Returns
Filename, as a string.
Category
System functions
Function syntax
GetFileFromPath(path)
See also
ExpandPath, GetCurrentTemplatePath
Parameters
Example
<h3>GetFileFromPath Example</h3>
<cfset thisPath = ExpandPath("*.*")>
<cfset thisDirectory = GetDirectoryFromPath(thisPath)>
<cfoutput>
The current directory is: #GetDirectoryFromPath(thisPath)#
<cfif IsDefined("FORM.yourFile")>
<cfif FORM.yourFile is not "">
<cfset yourFile = FORM.yourFile>
<cfif FileExists(ExpandPath(yourfile))>
<p>Your file exists in this directory. You entered the correct file
name, #GetFileFromPath("#thisPath#/#yourfile#")#
<cfelse>
<p>Your file was not found in this directory:
<br>Here is a list of the other files in this directory:
<!--- use cfdirectory to give the contents of the snippets
directory, order by name and size --->
<cfdirectory
directory = "#thisDirectory#"
name = "myDirectory"
sort = "name ASC, size DESC">
<!--- Output the contents of the cfdirectory as a cftable --->
<cftable query = "myDirectory">
<cfcol header = "NAME:" text = "#Name#">
<cfcol header = "SIZE:" text = "#Size#">
...
Parameter Description
path Absolute path (drive, directory, filename, and extension)