Use the CFDIRECTORY tag to handle all interactions with directories.
Note | The ColdFusion Server Basic security settings may prevent CFDIRECTORY from executing. These settings are managed using the ColdFusion Administrator Basic Security page. In order for CFDIRECTORY to execute, it needs to be enabled on the Basic Security page. |
If you write ColdFusion applications designed to run on a server that is used by multiple customers, you need to consider the security of the files and directories that could be uploaded or otherwise manipulated by CFDIRECTORY. Please refer to Administering ColdFusion Server for more information about securing ColdFusion tags.
<CFDIRECTORY ACTION="directory action" DIRECTORY="directory name" NAME="query name" FILTER="list filter" MODE="permission" SORT="sort specification" NEWDIRECTORY="new directory name">
Optional. Defines the action to be taken with directory(ies) specified in DIRECTORY. Valid entries are:
Required for all ACTIONs. The name of the directory you want the action to be performed against.
Required for ACTION="List". Ignored for all other actions. Name of output query for directory listing.
Optional for ACTION="List". Ignored for all other actions. File extension filter to be applied to returned names, for example: *.cfm
. Only one mask filter can be applied at a time.
Optional. Used with ACTION="Create" to define the permissions for a directory on Solaris or HP-UX. Ignored in Windows. Valid entries correspond to the octal values (not symbolic) of the UNIX chmod
command. Permissions are assigned for owner, group, and other, respectively. For example:
MODE=644
Assigns all, owner read/write permission, group and other read/write permissions.
MODE=666
Assigns read/write permissions for owner, group, and other.
MODE=777
Assigns read, write, and execute permissions for all.
Optional for ACTION="List". Ignored for all other actions. List of query columns to sort directory listing by. Any combination of columns from query output can be specified in comma separated list. ASC or DESC can be specified as qualifiers for column names. ASC is the default. For example:
SORT="dirname ASC, filename2 DESC, size, datelastmodified"
Required for ACTION="Rename". Ignored for all other actions. The new name of the directory specified in the DIRECTORY attribute.
When using the ACTION=LIST, CFDIRECTORY returns five result columns you can reference in your CFOUTPUT:
chmod
shell command.
You can use the following result columns in standard CFML expressions, preceding the result column name with the name of the query:
#mydirectory.Name# #mydirectory.Size# #mydirectory.Type# #mydirectory.DateLastModified# #mydirectory.Attributes# #mydirectory.Mode#
<!---------------------------------------------------------------------- This example shows the use of CFDIRECTORY to display the contents of the snippets directory in CFDOCS. -----------------------------------------------------------------------> <HTML> <HEAD> <TITLE> CFDIRECTORY Example </TITLE> </HEAD> <BODY> <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="c:\inetpub\wwwroot\cfdocs\snippets" 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> </BODY> </HTML>