JClientFtp

FTP client class

since

12.1

package

Joomla.Platform

Methods

__construct

JClientFtp object constructor

__construct(array $options = array()) 
since

12.1

Arguments

$options

arrayAssociative array of options to set

__destruct

JClientFtp object destructor

__destruct() 

Closes an existing connection, if we have one

since

12.1

_findMode

Method to find out the correct transfer mode for a specific file

_findMode(string $fileName) : integer
since

12.1

Arguments

$fileName

stringName of the file

Response

integerTransfer-mode for this filetype [FTP_ASCII|FTP_BINARY]

_mode

Set transfer mode

_mode(integer $mode) : boolean
since

12.1

Arguments

$mode

integerInteger representation of data transfer mode [1:Binary|0:Ascii] Defined constants can also be used [FTP_BINARY|FTP_ASCII]

Response

booleanTrue if successful

_passive

Set server to passive mode and open a data port connection

_passive() : boolean
since

12.1

Response

booleanTrue if successful

_putCmd

Send command to the FTP server and validate an expected response code

_putCmd(string $cmd, mixed $expectedResponse) : boolean
since

12.1

Arguments

$cmd

stringCommand to send to the FTP server

$expectedResponse

mixedInteger response code or array of integer response codes

Response

booleanTrue if command executed successfully

_verifyResponse

Verify the response code from the server and log response if flag is set

_verifyResponse(mixed $expected) : boolean
since

12.1

Arguments

$expected

mixedInteger response code or array of integer response codes

Response

booleanTrue if response code from the server is expected

append

Method to append a string to the FTP server

append(string $remote, string $buffer) : boolean
since

3.6.0

Arguments

$remote

stringFTP path to file to append to

$buffer

stringContents to append to the FTP server

Response

booleanTrue if successful

chdir

Method to change the current working directory on the FTP server

chdir(string $path) : boolean
since

12.1

Arguments

$path

stringPath to change into on the server

Response

booleanTrue if successful

chmod

Method to change mode for a path on the FTP server

chmod(string $path, mixed $mode) : boolean
since

12.1

Arguments

$path

stringPath to change mode on

$mode

mixedOctal value to change mode to, e.g. '0777', 0777 or 511 (string or integer)

Response

booleanTrue if successful

connect

Method to connect to a FTP server

connect(string $host = '127.0.0.1', string $port = 21) : boolean
since

12.1

Arguments

$host

stringHost to connect to [Default: 127.0.0.1]

$port

stringPort to connect on [Default: port 21]

Response

booleanTrue if successful

create

Method to create an empty file on the FTP server

create(string $path) : boolean
since

12.1

Arguments

$path

stringPath local file to store on the FTP server

Response

booleanTrue if successful

delete

Method to delete a path [file/folder] on the FTP server

delete(string $path) : boolean
since

12.1

Arguments

$path

stringPath to delete

Response

booleanTrue if successful

get

Method to get a file from the FTP server and save it to a local file

get(string $local, string $remote) : boolean
since

12.1

Arguments

$local

stringLocal path to save remote file to

$remote

stringPath to remote file to get on the FTP server

Response

booleanTrue if successful

getInstance

Returns the global FTP connector object, only creating it if it doesn't already exist.

getInstance(string $host = '127.0.0.1', string $port = '21', array $options = array(), string $user = null, string $pass = null) : \JClientFtp
static

You may optionally specify a username and password in the parameters. If you do so, you may not login() again with different credentials using the same object. If you do not use this option, you must quit() the current connection when you are done, to free it for use by others.

since

12.1

Arguments

$host

stringHost to connect to

$port

stringPort to connect to

$options

arrayArray with any of these options: type=>[FTP_AUTOASCII|FTP_ASCII|FTP_BINARY], timeout=>(int)

$user

stringUsername to use for a connection

$pass

stringPassword to use for a connection

Response

\JClientFtpThe FTP Client object.

isConnected

Method to determine if the object is connected to an FTP server

isConnected() : boolean
since

12.1

Response

booleanTrue if connected

listDetails

Method to list the contents of a directory on the FTP server

listDetails(string $path = null, string $type = 'all') : mixed
since

12.1

Arguments

$path

stringPath to the local file to be stored on the FTP server

$type

stringReturn type [raw|all|folders|files]

Response

mixedIf $type is raw: string Directory listing, otherwise array of string with file-names

listNames

Method to list the filenames of the contents of a directory on the FTP server

listNames(string $path = null) : string

Note: Some servers also return folder names. However, to be sure to list folders on all servers, you should use listDetails() instead if you also need to deal with folders

since

12.1

Arguments

$path

stringPath local file to store on the FTP server

Response

stringDirectory listing

mkdir

Method to create a directory on the FTP server

mkdir(string $path) : boolean
since

12.1

Arguments

$path

stringDirectory to create

Response

booleanTrue if successful

pwd

Method to retrieve the current working directory on the FTP server

pwd() : string
since

12.1

Response

stringCurrent working directory

quit

Method to quit and close the connection

quit() : boolean
since

12.1

Response

booleanTrue if successful

read

Method to read a file from the FTP server's contents into a buffer

read(string $remote,  &$buffer) : boolean
since

12.1

Arguments

$remote

stringPath to remote file to read on the FTP server

$buffer

Response

booleanTrue if successful

reinit

Method to reinitialise the server, ie. need to login again

reinit() : boolean

NOTE: This command not available on all servers

since

12.1

Response

booleanTrue if successful

rename

Method to rename a file/folder on the FTP server

rename(string $from, string $to) : boolean
since

12.1

Arguments

$from

stringPath to change file/folder from

$to

stringPath to change file/folder to

Response

booleanTrue if successful

restart

Method to restart data transfer at a given byte

restart(integer $point) : boolean
since

12.1

Arguments

$point

integerByte to restart transfer at

Response

booleanTrue if successful

setOptions

Set client options

setOptions(array $options) : boolean
since

12.1

Arguments

$options

arrayAssociative array of options to set

Response

booleanTrue if successful

size

Get the size of the remote file.

size(string $remote) : mixed
since

3.6.0

Arguments

$remote

stringFTP path to file whose size to get

Response

mixednumber of bytes or false on error

store

Method to store a file to the FTP server

store(string $local, string $remote = null) : boolean
since

12.1

Arguments

$local

stringPath to local file to store on the FTP server

$remote

stringFTP path to file to create

Response

booleanTrue if successful

syst

Method to system string from the FTP server

syst() : string
since

12.1

Response

stringSystem identifier string

write

Method to write a string to the FTP server

write(string $remote, string $buffer) : boolean
since

12.1

Arguments

$remote

stringFTP path to file to write to

$buffer

stringContents to write to the FTP server

Response

booleanTrue if successful

Properties

_conn

Socket resource

Type(s)

resource

_dataconn

Data port connection resource

Type(s)

resource

_pasv

Passive connection information

Type(s)

array

_response

Response Message

Type(s)

string

_timeout

Timeout limit

Type(s)

integer

_type

Transfer Type

Type(s)

integer

_autoAscii

Array to hold ascii format file extensions

Type(s)

array

_lineEndings

Array to hold native line ending characters

Type(s)

array

instances

JClientFtp instances container.

static

Type(s)

array