| Contents > CFML Reference > ColdFusion Tags > cfftp: Opening and closing FTP server connections |
|
|
|
|
||
To establish a connection with an FTP server, you use the open action with a connection attribute.
<cfftp
action = "action"
username = "name"
password = "password"
server = "server"
timeout = "timeout in seconds"
port = "port"
connection = "name"
proxyServer = "proxy server"
retryCount = "number"
stopOnError = "Yes" or "No"
passive = "Yes" or "No">
Attribute |
Req/Opt |
Default |
Description |
|---|---|---|---|
action |
Required |
|
FTP operation to perform.
|
username |
Required if |
|
User name to pass in the FTP operation. |
password |
Required if |
|
Password to log in the user. |
server |
Required if |
|
FTP server to which to connect; for example, |
timeout |
Optional |
30 |
Value in seconds for the timeout of all operations, including individual data request operations. |
port |
Optional |
21 |
Remote port to which to connect. |
connection |
Optional, but always used with |
|
Name of the FTP connection. If you specify the |
proxyServer |
Optional |
|
String. Name of proxy server (or servers) to use, if proxy access is specified. |
retryCount |
Optional |
1 |
Number of retries until failure is reported. |
stopOnError |
Optional |
No |
- cfftp.succeeded - Yes or No. - cfftp.errorCode - Error number. See the IETF Network - cfftp.errorText - Message text For conditional operations, use |
passive |
Optional |
No |
|
When you establish a connection with cfftp action="open" and specify a name in the connection attribute, ColdFusion caches the connection so that you can reuse it to perform additional FTP operations. When use a cached connection for subsequent FTP operations, you do not have to specify the username, password, or server connection attributes. The FTP operations that use the same connection name automatically use the information stored in the cached connection. Using a cached connection helps save connection time and improves file transfer performance.
You do not need to open a connection for single, simple, FTP operations, such as GetFile or PutFile.
To keep a 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 in all FTP operations, and you must use 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. If you do not assign the connection name to Session or Application variable, the connection remains open for the current page only, and you do not have to close it manually.
Changes to a cached connection, such as changing retryCount or timeout values, might require reestablishing the connection.
<p>cfftp lets users implement File Transfer Protocol operations.
By default, cfftp caches an open connection to an FTP server. <p>cfftp operations are usually of two types: <ul> <li>Establishing a connection <li>Performing file and directory operations </ul> <p>This example opens and verifies a connection, lists the files in a
directory, and closes the connection. <p>Open a connection <cfftp action = "open" username = "anonymous" connection = "My_query" password = "youremail@email.com" server = "ftp.tucows.com" stopOnError = "Yes"> <p>Did it succeed? <cfoutput>#cfftp.succeeded#</cfoutput> <p>List the files in a directory: <cfftp action = "LISTDIR" stopOnError = "Yes" name = "ListFiles" directory = "/" connection = "my_query"> <cfoutput query = "ListFiles"> #name#<br> </cfoutput> <p>Close the connection: <cfftp action = "close" connection = "My_query" stopOnError = "Yes"> <p>Did it succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
|
|
||
| Contents > CFML Reference > ColdFusion Tags > cfftp: Opening and closing FTP server connections |
|
|
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. 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.1/htmldocs/tags-p40.htm
Comments
TomChiv said on Jul 1, 2004 at 9:16 AM : Adam Cameron said on Jan 12, 2005 at 12:18 PM : No screen name said on Jan 18, 2005 at 8:37 PM : jehiah said on Jun 28, 2005 at 5:42 PM :