## FtpClient

    Object
       |
       +--FtpClient

Deprecated use {link helma.Ftp} instead
Defined in FtpClient.js

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Constructor Summary
`FtpClient(<String> server)` Constructor for File objects, to send and receive files from an FTP server.

Methods Summary
`void` | `ascii()` Sets transfer mode to ascii for transmitting text-based data.
`void` | `binary()` Sets transfer mode to binary for transmitting images and other non-text files.
`void` | `cd(<String> dir)` Changes the working directory on the FTP server.
`void` | `getFile(<String> source,<String> dest)` Transfers a file from the FTP server to the local file system.
`String` | `getString(<String> source)` Retrieves a file from the FTP server and returns it as string.
`void` | `lcd(<String> dir)` Changes the working directory of the local machine when being connected to an FTP server.
`Boolean` | `login(<String> username,<String> password)` Logs in to the FTP server.
`void` | `logout()` Terminates the current FTP session.
`Boolean` | `mkdir(<String> name)` Creates a new directory on the server.
`Boolean` | `putFile(<String> dest)` Transfers a file from the local file system to the remote server.
`Boolean` | `putString(<String> source,<String> dest)` Transfers text from a string to a file on the FTP server.

Constructor Detail

### FtpClient

    FtpClient(<String> server)

Constructor for File objects, to send and receive files from an FTP server.
The FTP client needs Daniel Savarese's NetComponents library in the classpath in order to work.
Example:

     var ftp = new FtpClient("ftp.mydomain.com");

Parameters:

`server` - as String, the address of the FTP Server to connect to

Deprecated use {link helma.Ftp} instead

Method Detail

### ascii

    void ascii()

Sets transfer mode to ascii for transmitting text-based data.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");
     ftp.ascii();

### binary

    void binary()

Sets transfer mode to binary for transmitting images and other non-text files.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");
     ftp.binary();

### cd

    void cd(<String> dir)

Changes the working directory on the FTP server.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");

     // use absolute pathname
     ftp.cd("/home/users/fred/www");

     // change to parent directory
     ftp.cd("..");

     // use relative pathname
     ftp.cd("images");

Parameters:

`dir` - as String, the path that the remote working directory should be changed to

### getFile

    void getFile(<String> source,<String> dest)

Transfers a file from the FTP server to the local file system.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");
     ftp.getFile(".htaccess", "htaccess.txt");

Parameters:

`source` - as String, the name of the file that should be downloaded

`dest` - as String, the name which the file should be stored under

See:

- cd()
- lcd()

### getString

    String getString(<String> source)

Retrieves a file from the FTP server and returns it as string.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");
     var str = ftp.getString("messages.txt");

Parameters:

`source` - as String, the name of the file that should be downloaded

Returns:

String containing the data of the downloaded file

See:

- cd()

### lcd

    void lcd(<String> dir)

Changes the working directory of the local machine when being connected to an FTP server.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");

     // use absolute pathname
     ftp.lcd("/home/users/fred/www");

     // change to parent directory
     ftp.lcd("..");

     // use relative pathname
     ftp.lcd("images");

Parameters:

`dir` - as String, the path that the local working directory should be changed to

### login

    Boolean login(<String> username,<String> password)

Logs in to the FTP server.
The function returns true if successful, false otherwise
Example:

     var ftp = new FtpClient("ftp.host.dom");
     if (ftp.login("user", "pass"))
       res.write("User logged in.");
     else
       res.write("Unable to log in.");

     User logged in.

Parameters:

`username` - as String

`password` - as String

Returns:

Boolean true if the login was successful, otherwise false

### logout

    void logout()

Terminates the current FTP session.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");
     ftp.putFile("htaccess.txt", ".htaccess");
     ftp.logout();

### mkdir

    Boolean mkdir(<String> name)

Creates a new directory on the server.
The name of the directory is determined as the function's string parameter. Returns false when an error occured (e.g. due to access restrictions, directory already exists etc.), otherwise true.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");
     if (ftp.mkdir("testdir"))
       ftp.cd("testdir")
     else
       ftp.logout();

Parameters:

`name` - as String, the name of the directory to be created

Returns:

Boolean true if the directory was successfully created, false if there was an error

### putFile

    Boolean putFile(<String> dest)

Transfers a file from the local file system to the remote server.
Returns true if the transmission was successful, otherwise false.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");
     if (ftp.putFile("testfile"))
       res.write("File transferred successfully.");
     else
       res.write("Transfer error.");

     File transferred successfully.

Parameters:

`dest` - as String, the name of the destination file to be uploaded

Returns:

Boolean true if the file was successfully uploaded, false if there was an error

### putString

    Boolean putString(<String> source,<String> dest)

Transfers text from a string to a file on the FTP server.
Example:

     var ftp = new FtpClient("ftp.host.dom");
     ftp.login("user", "pass");
     ftp.putString("Hello, World!", "message.txt");

Parameters:

`source` - as String, the text content that should be uploaded

`dest` - as String, the name of the remote destination file

Returns:

Boolean true if the file was successfully uploaded, false if there was an error

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Documentation generated by JSDoc on Thu Apr 5 01:59:00 2007