You can find the CFFiddle demo of this function and other file functions as part of a project that is shared with you.

Click the button below to launch CFFiddle.

To copy the project in your workspace in CFFiddle, follow the steps below:

  1. Log in with your Gmail or Facebook credentials.
  2. Navigate to the project in the left pane.
  3. Once you make some changes in any cfm in the project, a pop up displays asking you to save the project.
  4. Give the project a suitable name and click Save.
  5. Create a folder named dir1 and upload a text file, myfile.txt.


Extracts a filename from an absolute on-disk or in-memory path.


Filename, as a string.


System functions

Function syntax


See also






Absolute on-disk or in-memory path.


<h3>GetFileFromPath Example</h3>
<cfset thisPath = ExpandPath("*.*")>
<cfset thisDirectory = GetDirectoryFromPath(thisPath)>
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#")#
<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 --->
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#">


This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy