cfftp

Lets users implement File Transfer Protocol (FTP) operations.

  <cfftp action="open">

 cfftp(action="open");

Attribute Reference

action string
Required

FTP operation to perform.
open: create an FTP connection
close: terminate an FTP connection
Values:
  • open
  • close
  • changedir
  • createdir
  • listdir
  • removedir
  • getfile
  • putfile
  • rename
  • remove
  • getcurrentdir
  • getcurrenturl
  • existsdir
  • existsfile
  • exists
  • quote
  • site
  • allo
  • acct

username string

Overrides username specified in ODBC setup.

password string

Overrides password specified in ODBC setup.

server string

FTP server to which to connect; for example,
ftp.myserver.com

timeout numeric
Default: 30

Value in seconds for the timeout of all operations,
including individual data request operations.

port numeric
Default: 21

Remote port to which to connect

connection variableName

Name of the FTP connection. If you specify the username,
password, and server attributes, and if no connection
exists for them, CFML creates one. Calls to cfftp
with the same connection name reuse the connection.

proxyserver string

The proxy server required to access the URL.

retrycount numeric
Default: 1

Number of retries until failure is reported.

stoponerror boolean
Default: false

Yes: halts processing, displays an appropriate error.
No: populates the error variables
Values:
  • true
  • false

passive boolean
Default: false

Yes: enable passive mode
Values:
  • true
  • false

transfermode string
Default: auto

ASCII FTP transfer mode
Binary FTP transfer mode
Auto FTP transfer mode
Values:
  • auto
  • ascii
  • binary

failifexists boolean
Default: true

Yes: if a local file with same name exists, getFile fails
Values:
  • true
  • false

directory string

Directory on which to perform an operation

localfile string

Name of the file on the local file system

remotefile string

Name of the file on the FTP server file system.

item string

Object of these actions: file or directory.

existing string

Current name of the file or directory on the remote server.

new string

New name of file or directory on the remote server

name string

Query name of directory listing.

result string

Specifies a name for the structure in which cfftp
stores the returnValue variable. If set, this value
replaces cfftp as the prefix to use when accessing
returnVariable.

attributes string

Attributes of the current element: normal or Directory.

passphrase string

CF 8+ Used when key is specified. Because private keys are stored in an encrypted form on the client host, the user must supply a passphrase to enable generating the signature.

buffersize numeric

Buffer size in bytes.

secure string
Default: false

CF 8+ yes: enables secure FTP
Values:
  • true
  • false

asciiextensionlist string

Delimited list of file extensions that force ASCII
transfer mode, if transferMode = "auto".

key string

CF 8+ Public-key-based authentication. Refers to the absolute path to the private key of the user.
Possession of a private key provides authentication by sending a signature created with a private key.
The server must ensure that the key is a valid authentication for the user and that the signature is valid.
Both must be valid to accept the authentication.

actionparam string

Used only when action is quote, site, or acct. Specifies the command when action is quote or site; specifies account information when action is acct.

fingerprint string

CF 8+ Fingerprint of the host key in the form ssh-dss.ssh-rsa, which is a 16-byte unique identifier for the server attribute that you specify.

systemtype string

CF 11.0.3+ Specifies how to parse file list response, specify WINDOWS or UNIX or a class which implements org.apache.commons.net.ftp.FTPFileEntryParser
Values:
  • WINDOWS
  • UNIX

Compatibility

Lucee:

Lucee support for authentication by public key was added in version 5.2.7.38.

Links more information about cfftp

Examples
Sample code using the cfftp tag

CF 9+ using the CFIDE script components

// Create FTP service and set attributes for connection 
 ftpService = new ftp(); 
 ftpService.setConnection("myConn"); 
 ftpService.setUsername("myUName"); 
 ftpService.setPassword("myPW"); 
 ftpService.setServer("ftp.server.com"); 
 ftpService.setStopOnError(true); 
 // Open connection 
 ftpService.open(); 
 // Get list of dir 
 fileList = ftpService.listdir(directory = "/ ", name="fileList", stopOnError = true).getResult(); 
 // Close connection 
 ftpService.close();

<cfftp action="open" connection="myConn" username="myUName" password="myPW" server="ftp.server.com" stopOnError="true">

<cfftp action="listdir" connection="myConn" name="filesList" directory="/" stopOnError="true">

<cfftp action="close" connection="myConn" stopOnError="true">

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub