After you establish a connection with cfftp, you can reuse it to perform additional FTP operations. To do this, you use the connection attribute to define and name an FTP connection object that stores information about the connection. Any FTP operations that use the same connection name automatically use the information stored in the connection object. This helps save connection time and improves file transfer performance.
To keep the connection open throughout a session or longer, you can use a session or application variable as the connection name. However, if you do this, you must specify the full variable name, with the close action, when you are finished. Keeping a connection open prevents others from using the FTP server; so close a connection as soon as possible.
Changes to a cached connection, such as changing retryCount or timeout values, might require reestablishing the connection.
The following example opens a connection and gets a file listing showing file or directory name, path, URL, length, and modification date.
<p>Open a connection
<cfftp connection = "myConnection"
username = "myUserName"
password = "myUserName@allaire.com"
server = "ftp.allaire.com"
action = "open"
stopOnError = "Yes">
<p>Did it succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
<cfftp connection = "myConnection"
action = "LISTDIR"
stopOnError = "Yes"
name = "ListDirs"
directory = "/">
<p>FTP Directory Listing:<br>
<cftable query = "ListDirs" HTMLTable = "Yes" colHeaders = "Yes">
<cfcol header = "<b>Name</b>" text = "#name#">
<cfcol header = "<b>Path</b>" text = "#path#">
<cfcol header = "<b>URL</b>" text = "#url#">
<cfcol header = "<b>Length</b>" text = "#length#">
<cfcol header = "<b>LastModified</b>"
text = "Date(Format#lastmodified#)">
<cfcol header = "<b>IsDirectory</b>" text = "#isdirectory#">
</cftable>
<p>Close the connection:
<cfftp connection = "myConnection"
action = "close"
stopOnError = "Yes">
<p>Did it succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
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-pt142.htm
Comments
LineNoize said on Mar 24, 2003 at 3:14 PM :