Manages interactions with directories.
Note: For this tag execute, it must be enabled in the ColdFusion Administrator. For more information, see Administering ColdFusion MX.
If you put ColdFusion applications on a server that is used by multiple customers, you must consider the security of files and directories that could be uploaded or otherwise manipulated with this tag by unauthorized users. For more information about securing ColdFusion tags, see Administering ColdFusion MX.
<cfdirectory action = "directory action" directory = "directory name" name = "query name" filter = "list filter" mode = "permission" sort = "sort specification" newDirectory = "new directory name">
New in ColdFusion MX: On Windows, if cfdirectory action = "list", this tag does not return the directory entries "." (dot) or ".." (dot dot), which represent "the current directory" and "the parent directory." (In earlier releases, ColdFusion returned these entries.)
<cfdirectory action = "list" directory ="c:\" name="foo>
Files in c:\<br>
<cfloop query = "foo" startrow = 3>
#name#<br>
>
<cfdirectory directory="c:\" name="foo">
Files in c:\<br>
<cfoutput query="foo">
<cfif NOT foo.name is "." AND NOT foo.name is "..">
#name#<br>
</cfif>
</cfoutput>
If action = "list", cfdirectory returns these result columns, which you can reference in a cfoutput tag:
name: directory entry name. The entries "." and ".." are not returned.
size: directory entry sizetype: file type: File, for a file; Dir, for a directorydateLastModified: the date that an entry was last modifiedattributes: file attributes, if applicablemode: (UNIX and Linux only) see the UNIX man pages, chmod shell command.You can use the following result columns in standard CFML expressions, preceding the result column name with the query name:
#mydirectory.name#
#mydirectory.size# #mydirectory.type# #mydirectory.dateLastModified# #mydirectory.attributes# #mydirectory.mode#
<h3>cfdirectory Example</h3>
<!--- use cfdirectory to give the contents of the snippets directory,
order by name and size (you may need to modify this path) --->
<cfdirectory
directory="#GetDirectoryFromPath(GetTemplatePath())#"
name="myDirectory"
sort="name ASC, size DESC">
<!---- Output the contents of the cfdirectory as a cftable ----->
<cftable
query="myDirectory"
htmltable
colheaders>
<cfcol
header="NAME:"
text="#Name#">
<cfcol
header="SIZE:"
text="#Size#">
</cftable>
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.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/Tags-pt121.htm
Comments
hlichtin said on Jan 28, 2003 at 3:31 PM : aeverett said on Aug 26, 2002 at 7:54 PM : Alex Peterson said on Aug 18, 2003 at 11:43 AM : sean9999 said on Sep 23, 2003 at 12:20 PM : ReganEngamn said on Jan 9, 2004 at 5:03 PM : tobylaroni said on May 18, 2005 at 10:58 AM :