GETDIRECTORYFROMPATH  
Description

Extracts a directory from an absolute path.

 
Returns

Absolute path, without the filename. The last character is a forward or backward slash, depending on the operating system.

 
Category

System functions

 
Function syntax
GetDirectoryFromPath(path)
 
See also

ExpandPath, GetFileFromPath

 
Parameters

 
Example
<h3>GetDirectoryFromPath 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 show directory, order by name & 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#">
      </cftable>
      </cfif>
   </cfif>
<cfelse>
   <H3>Please enter a file name</H3>
   </cfif>
   </cfoutput>
   <form action="getdirectoryfrompath.cfm" METHOD="post">
      <H3>Enter the name of a file in this directory <I><FONT SIZE="-1">
(try expandpath.cfm)</FONT></I></H3>
      <input type="Text" NAME="yourFile">
      <input type="Submit" NAME="">
   </form> --->

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

PATH