CFFTP: CONNECTING TO AN FTP SERVER | |
Description
To establish a connection with an FTP server, you use the connection attribute. | |
Syntax<cfftp action = "action" username = "name" password = "password" server = "server" timeout = "timeout in seconds" port = "port" connection = "name" proxyServer = "proxyserver" retryCount = "number" stopOnError = "Yes" or "No" passive = "Yes" or "No"> | |
See also
cfhttp, cfldap, cfmail, cfpop
|
|
Usage
If you use connection caching to an active FTP connection, you do not have to respecify the username, password, or server connection attributes: Changing a cached connection, such as changing retryCount or timeout values, might require reestablishing the connection. |
|
Example<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> |
ACTION | |
Required | |
FTP operation to perform.
For more information, see cfftp: Connection caching. |
USERNAME | |
Required if action = "open" | |
User name to pass in the FTP operation. |
PASSWORD | |
Required if action = "open" | |
Password to log in the user. |
SERVER | |
Required if action = "open" | |
FTP server to which to connect; for example, ftp.myserver.com |
TIMEOUT | |
Optional | |
Default value: "30"
Value in seconds for the timeout of all operations, including individual data request operations. |
PORT | |
Optional | |
Default value: "21"
Remote port to which to connect. |
CONNECTION | |
Optional | |
Name of the FTP connection. Used to cache a new FTP connection or to reuse a connection. If you specify the username, password, and server attributes, and if no connection exists for them, ColdFusion creates one. Calls to cfftp with the same connection name reuse the connection information. |
PROXYSERVER | |
Optional | |
String. Name of proxy server (or servers) to use, if proxy access is specified. |
RETRYCOUNT | |
Optional | |
Default value: "1 "
Number of retries until failure is reported. |
STOPONERROR | |
Optional | |
Default value: "No"
For conditional operations, use cfftp.errorCode. Do not use cfftp.errorText for this purpose. |
PASSIVE | |
Optional | |
Default value: "No"
|