cfdirectory

Description

Handles interactions with directories.

Category

File management tags


Note

In the ColdFusion Administrator, the security settings on the Tag Restrictions page under ColdFusion Basic Security may prevent cfdirectory from executing. In order for cfdirectory to execute, it needs to be enabled. For more information, see Advanced ColdFusion Administration.


If you write ColdFusion applications that run on a server used by multiple customers, you must consider the security of the files and directories that could be uploaded or otherwise manipulated by cfdirectory. For more information about securing ColdFusion tags, see Advanced ColdFusion Administration.

Syntax


<cfdirectory action = "directory action"

  directory = "directory name"

  name = "query name"

  filter = "list filter"

  mode = "permission"

  sort = "sort specification"

  newDirectory = "new directory name"> 

See also

cffile

Attributes

Attribute
Description
action
Optional. Defines the action to be taken with directory(ies) specified in directory. Options are:
  • list (default)
  • create
  • delete
  • rename
directory
Required. The name of the directory to perform the action against.
name
Required for action = "list". Ignored by all other actions. Name of output query for directory listing.
filter
Optional for action = "list". Ignored by all other actions. File extension filter applied to returned names. For example: *.cfm. Only one mask filter can be applied at a time.
mode
Optional. Used with action = "Create" to define the permissions for a directory on UNIX and Linux platforms. Ignored on Windows. Options correspond to the octal values of the UNIX chmod command. From left to right, permissions are assigned for owner, group, and other.
For example:
  • mode = "644"    Assigns read/write permissions for the owner, and read permissions for the group and other.
  • mode = "666"    Assigns read/write permissions for owner, group, and other.
  • mode = "777"    Assigns read, write, and execute permissions for all.
sort
Optional for action = "list". Ignored by all other actions. The query columns by which to sort the directory listing. Any combination of columns from query output can be specified in comma-separated list. You can specify ASC (ascending) or DESC (descending) as qualifiers for column names. ASC is the default. For example:
sort = "dirname ASC, filename2 

  DESC, size, datelastmodified"

newDirectory
Required for action = "rename". Ignored by all other actions. The new name of the directory specified in the directory attribute.

Usage

When using the action = "list", cfdirectory returns five result columns you can reference in your cfoutput:

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# 

Example

<!---------------------------------------------------------------------

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>    



Banner.Novgorod.Ru