ar\connect\ftp

This module provides a simple API to access FTP servers. 

Example 1: Anonymous file retrieval.

<pinp>
$file = ar('connect/ftp')
->get( 'ftp://ftp.muze.nl/pub/ariadne/ariadne-latest.tgz' );
</pinp>

Example 2: Using the client API

<pinp>
$client = ar('connect/ftp')->client();
$client
->connect( 'ftp.muze.nl' )
->login( 'anonymous', 'guest' )
->cd( '/pub/ariadne/');
$file = $client->get( 'ariadne-latest.tgz' );
</pinp>

methods

(object) client This method returns an FTP client object..
(void) configure Allows you to change the default settings for the FTP api.
(string) get This method downloads a file from an FTP server.
(void) put This method uploads a file to an FTP server.

configure

(void) ar('connect/ftp')->configure( $option, $value )

(string)$optionThe name of the option.
(mixed)$valueThe value of the option.

Configures global options for the ftp module. Valid options are:

(int)timeoutThe timeout in seconds, default is 90 seconds.
(bool)pasvWhether or not to enable passive mode, default is false.
(int)transferModeThe transfer mode, default is FTP_BINARY, can also be set to FTP_ASCII.

get

(string) ar('connect/ftp')->get( $url, $options = array() )


put

(bool) ar('connect/ftp')->put( $url, $contents, $options = array() )


client

(object) ar('connect/ftp')->client( $url = null, $options = array() )

(string) $url The URL to the FTP site. May include a username/password and directory information. Anything after the last '/' is ignored.
(array) $options An array with some options for the FTP connection.

This method creates a new FTP client object and returns it. If a url was given, it is parsed and the connection is made. The options can be any of:

(int) mode Can be either FTP_ASCII or FTP_BINARY
(bool) pasv If true, the client will use passive mode to transfer files.

client methods

(object) cd Changes the current directory on a FTP server.
(object) chmod Set permissions on a file via FTP.
(object) connect Opens an FTP connection.
(object) delete Deletes a remote file from the FTP server.
(object) disconnect Closes an FTP connection.
(string) get Retrieves a remote file from the FTP server.
(object) login Logs in to the FTP connection.
(array) ls Returns an array of filenames from the specified directory.
(int) mdtm Gets the last modified time for a remote file.
(object) mkdir Creates the specified directory on the FTP server.
(object) mode Sets the transfer mode to either ASCII or binary.
(object) pasv Turns on or off passive mode.
(object) put Uploads the data to a remote file on the FTP server.
(string) pwd Returns the current directory name.
(object) rename Renames a file or a directory on the FTP server.
(int) size Returns the size of the given file in bytes.

cd

(object) $ftpClient->cd( $dir )

(string)$dirThe name of the directory to change to.

Changes the current directory on a FTP server. Returns the client object or an error.

chmod

(object) $ftpClient->chmod( $mode, $filename )

(int)$modeThe new persmissions, given as an octal value.
(string)$filenameThe remote file.

Sets the permissions on the specified remote file to mode. Returns the client.

connect

(object) $ftpClient->connect( $host, $port = 21 )


delete

(object) $ftpClient->delete( $file )


disconnect

(object) $ftpClient->disconnect()


get

(string) $ftpClient->get( $file, $options = array() )


login

(object) $ftpClient->login( $username, $password = null )


ls

(object) $ftpClient->ls()


mdtm

(object) $ftpClient->mdtm( $filename )


mkdir

(object) $ftpClient->mkdir( $filename )


mode 

(object) $ftpClient->mode( $mode )


pasv

(object) $ftpClient->pasv( $pasv = true )


put

(object) $ftpClient->put( $filename, $contents, $options = array() )


pwd

(string) $ftpClient->pwd()


rename

(object) $ftpClient->rename( $name, $newname )


size 

(int) $ftpClient->size( $filename )