Accessing FTP Servers ColdFusion Help

In many ways, the CFFTPtag is a close relative of the CFHTTPtag that you learned about in the preceding chapter. Whereas the CFHTTPtag enables you to use the Hypertext Transfer Protecol (HITP) to access Web servers, CFFTPenables you to use the File Transfer Protocol (FfP) to access FfP servers.

Many Web users don’t realize that much of the data they are accessing is being served to the Internet by FfP servers as opposed to Web servers. ‘This fact is almost hidden, because it is so easy for a Web page to contain a link to a file on an FfP server, that the user never needs to know the difference. Sites that offer large numbers of files, such as software archives or document repositories, often rely on FfP to make those documents available. After all, FTP was designed for the task, and, in some ways, is still better suited to it than HITP.

In this chapter, you will learn how to connect to FfP servers, then proceed to upload and download files.’and to perform other tasks on the files and directories that are on the server.

Connecting to FTPServers

Using an FfP server with the CFFTPtag requires two main steps:
1. Connecting to the server.
2. Performing file and directory operations once connected.

Distinguishing between these two roles of the CFFTPtag is achieved with the AaION attribute. ‘This attribute takes two possible values when dealingwith establishing or ending connections:
• Open
• Close
Other attributes that are used after a connection is established are discussed later-in the section titled “Manipulating Files and Directories on the Server.” At its simplest, connecting to an FfP server requires three attributes of the CFFTPtag:

For example, to connect to the server ftp . some . domain as use  using the password pass, you could use the following tag:

However, this approach doesn’t address some fundamental issues, including using a proxy server, establishing a passive connection, connecting as an anonymous user, handling special cases such as poor connections, and handling errors.

Connecting through a Proxy Server

If you are behind a firewall and need to connect to a remote FTP server through a proxy server, you can use the PROXYSERVER attribute of the CFFTP tag. This attribute takes the hostname or IP address of your proxy server as a value. For instance, to establish a c<;mnection
to ftp. some. domai n as the user userl with password pasl using the proxy server proxy. my.domai n, use the following CFFTP tag:

PASSWORD- ,.pass1 ”

Establishing a Passive )connetion

Some FfP servers require that’ they be accessed using a passive connection, If you need to establish a passive connection, use the PASSIVE attribute of the CFFTP tag. Possible values are YES and NO; the value is NO, Set the attribute to YES to establish a passive connection:

Making Anonymous FTP Connections

If an FTP server allows anonymous connections for the purpose of downloading files, then the general rule is that the-user making the connection must provide the username anonymous (most servers also accept ftp as an alternative), and their e-mail address as a password. For instance, the following lines:

PASSWORD- ,.userHtsomewhere. com”)

establish an anonymous connection to ftp.some.domain.

Posted on November 16, 2015 in Accessing FTP Servers

Share the Story

Back to Top
Share This