cfdirectory tag lists
directory contents and creates, renames, and deletes directories on
your ColdFusion application server. In an application such as a
document management system, the
allows you to do such tasks as list all the documents stored in a
particular folder or build a Windows Explorer-style view of files and
folders on your server. Because the
tag provides direct access to your ColdFusion
server’s filesystem, it may represent a security
concern depending on the nature of your server environment. If you
wish, the tag can be disabled from the Sandbox Security section in
the ColdFusion Administrator.
As just noted,
cfdirectory tag lists the contents of any
directory on the ColdFusion server. Example 12-1 uses
cfdirectory tag to list the contents of the
root directory on the C drive of the ColdFusion server.
Example 12-1. Listing a directory with cfdirectory
<cflock name="CLock" type="ReadOnly" timeout="30"> <cfdirectory action="List" directory="c:\" name="MyQuery" filter="*.*" sort="Type Asc, Name Asc"> </cflock> <table border="1"> <tr> <th>Name</th><th>Size</th><th>Type</th><th>Last Modified</th> <th>Attributes</th><th>Mode</th> </tr> <cfoutput query="MyQuery"> <tr> <td>#Name#</td><td>#Size#</td><td>#Type#</td><td>#DateLastModified#</td> <td>#Attributes#</td><td>#Mode#</td> </tr> </cfoutput> </table>
The first attribute,
action, tells ColdFusion what
cfdirectory operation ...