GetFileFromPath

Description

Extracts a filename from an absolute path.

Return value

File name, as a string.

Category

System functions

Syntax

GetFileFromPath(path)

See also

ExpandPath, GetCurrentTemplatePath

Parameters

Parameter Description
path
Absolute path (drive, directory, filename, and extension)

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#">
...

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt194.htm