Returns the global FTP connector object, only creating it if it doesn't already exist.
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.
static
JClientFtp
getInstance
([
string $host =
'127.0.0.1'], [
string $port =
'21'], [
array $options =
array()], [
string $user =
null], [
string $pass =
null])
-
string
$host: Host to connect to
-
string
$port: Port to connect to
-
array
$options: Array with any of these options: type=>[FTP_AUTOASCII|FTP_ASCII|FTP_BINARY], timeout=>(int)
-
string
$user: Username to use for a connection
-
string
$pass: Password to use for a connection
JClientFtp object constructor
JClientFtp
__construct
([array $options = array()])
-
array
$options: Associative array of options to set
Redefined in descendants as:
JClientFtp object destructor
Closes an existing connection, if we have one
void
__destruct
()
Method to change the current working directory on the FTP server
boolean
chdir
(string $path)
-
string
$path: Path to change into on the server
Method to change mode for a path on the FTP server
boolean
chmod
(string $path, mixed $mode)
-
string
$path: Path to change mode on
-
mixed
$mode: Octal value to change mode to, e.g. '0777', 0777 or 511 (string or integer)
Method to connect to a FTP server
boolean
connect
([string $host = '127.0.0.1'], [string $port = 21])
-
string
$host: Host to connect to [Default: 127.0.0.1]
-
string
$port: Port to connect on [Default: port 21]
Method to create an empty file on the FTP server
boolean
create
(string $path)
-
string
$path: Path local file to store on the FTP server
Method to delete a path [file/folder] on the FTP server
boolean
delete
(string $path)
-
string
$path: Path to delete
Method to get a file from the FTP server and save it to a local file
boolean
get
(string $local, string $remote)
-
string
$local: Local path to save remote file to
-
string
$remote: Path to remote file to get on the FTP server
Method to determine if the object is connected to an FTP server
boolean
isConnected
()
Method to list the contents of a directory on the FTP server
mixed
listDetails
([string $path = null], [string $type = 'all'])
-
string
$path: Path to the local file to be stored on the FTP server
-
string
$type: Return type [raw|all|folders|files]
Method to list the filenames of the contents of a directory on the FTP server
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
string
listNames
([string $path = null])
-
string
$path: Path local file to store on the FTP server
Method to login to a server once connected
boolean
login
([string $user = 'anonymous'], [string $pass = 'jftp@joomla.org'])
-
string
$user: Username to login to the server
-
string
$pass: Password to login to the server
Method to create a directory on the FTP server
boolean
mkdir
(string $path)
-
string
$path: Directory to create
Method to retrieve the current working directory on the FTP server
string
pwd
()
Method to quit and close the connection
boolean
quit
()
Method to read a file from the FTP server's contents into a buffer
boolean
read
(string $remote, string &$buffer)
-
string
$remote: Path to remote file to read on the FTP server
-
string
&$buffer: Buffer variable to read file contents into
Method to reinitialise the server, ie. need to login again
NOTE: This command not available on all servers
boolean
reinit
()
Method to rename a file/folder on the FTP server
boolean
rename
(string $from, string $to)
-
string
$from: Path to change file/folder from
-
string
$to: Path to change file/folder to
Method to restart data transfer at a given byte
boolean
restart
(integer $point)
-
integer
$point: Byte to restart transfer at
Set client options
boolean
setOptions
(array $options)
-
array
$options: Associative array of options to set
Method to store a file to the FTP server
boolean
store
(string $local, [string $remote = null])
-
string
$local: Path to local file to store on the FTP server
-
string
$remote: FTP path to file to create
Method to system string from the FTP server
string
syst
()
Method to write a string to the FTP server
boolean
write
(string $remote, string $buffer)
-
string
$remote: FTP path to file to write to
-
string
$buffer: Contents to write to the FTP server
Method to find out the correct transfer mode for a specific file
integer
_findMode
(string $fileName)
-
string
$fileName: Name of the file
Set transfer mode
boolean
_mode
(integer $mode)
-
integer
$mode: Integer representation of data transfer mode [1:Binary|0:Ascii] Defined constants can also be used [FTP_BINARY|FTP_ASCII]
Set server to passive mode and open a data port connection
boolean
_passive
()
Send command to the FTP server and validate an expected response code
boolean
_putCmd
(string $cmd, mixed $expectedResponse)
-
string
$cmd: Command to send to the FTP server
-
mixed
$expectedResponse: Integer response code or array of integer response codes
Verify the response code from the server and log response if flag is set
boolean
_verifyResponse
(mixed $expected)
-
mixed
$expected: Integer response code or array of integer response codes