Getting a Directory Listing ColdFusion Help

In working with the files on an FfP server, you often need to download a directory listing of files on the server to present in a ColdFusion template. You achieve this by using the ACTION=II  ” attribute, combined with the NAMEand DIRECTORYattributes.

The resulting query contains the columns described in the following list:
Name Filename of the element specified by the cur:ent row of the query
Path File path of the current row of the query (without a drive specified)
URL Full URL of the element specified by the current row of the query
Length File size of the element specified by the current row of the query
Last Modi fied Modification date of the element specified by the current row of the query
Attributes File attributes of the element specified by the current row of the query
IsDirectory A Boolean value indicating whether the element specified by the current row of the query is a directory (a True value) or a file (a False value)
Mode Octal string representing UNIX permissions

Using this information, you can display the contents of a directory you have listed:

Notice the use of a test on the Boolean IsO; rectory value to determine whether an element is a directory, and whether it is to put a / after the name (a typical Unix and FfP convention for specifying directories). You can take this a step further, and make all files clickable so that users can download the files. This can be done with the URL value:

Changing Directories

Finally, you will look at changing directories, another critical action in being able to navigate an FfP server and upload and download files. You change directories by using .ACTION=C”hangeD; r’ and the DIRECTORYattribute.’
For instance, if the. current directory has a subdirectory called pub, you could change the current directory to the pub directory with the following tag:

<CFFTP CONNECTION-‘MyFtp’
ACTION-‘ChangeD;r’
DIRECTORY-‘pub’>

Also, just as the two-dot ( .. ) combination indicates the parent directory of the current directory when using the cd command in DOS or Unix, it can also be used to change to the parent directory of the current directory when using the ACTION””Chanqefri ” attribute:

Where Do We Go from Here?

In the next’chapter, you will look at the last Internet protocol discussed in this section of the book: Lightweight Directory Access Protocol, or LDAP. LDAP is used to create directory structures for the hierarchical storage of information about people and resources within organizations. Many -f the Internet white-pages services that are used on the Web to locate phone numbers and e- ail addresses are based on LDAP servers.

The next chapter won’t address the intricacies of setting up your ownLDAP server, which can be quite complex. Instead, you will start with an overview of what LDAP is and how it is structured, and then move on to using the CFLDAPserver to access public Internet white pages running on an LDAP server.

Posted on November 16, 2015 in Accessing FTP Servers

Share the Story

Back to Top
Share This