FtpClient
FTP client class
since |
1.5 |
---|---|
package |
Joomla CMS |
Methods
__construct
FtpClient object constructor
__construct(mixed||string|int options = []) :
since |
1.5 |
---|
Arguments
- options
array<string|int, mixed>
Associative array of options to set
Response
mixed
__destruct
FtpClient object destructor
__destruct() :
Closes an existing connection, if we have one
since |
1.5 |
---|
Response
mixed
_findMode
Method to find out the correct transfer mode for a specific file
_findMode( fileName) :
since |
1.5 |
---|
Arguments
- fileName
string
Name of the file
Response
int
Transfer-mode for this filetype [FTP_ASCII|FTP_BINARY]
_mode
Set transfer mode
_mode( mode) :
since |
1.5 |
---|
Arguments
- mode
int
Integer representation of data transfer mode [1:Binary|0:Ascii] Defined constants can also be used [FTP_BINARY|FTP_ASCII]
Response
bool
True if successful
_passive
Set server to passive mode and open a data port connection
_passive() :
since |
1.5 |
---|
Response
bool
True if successful
_putCmd
Send command to the FTP server and validate an expected response code
_putCmd( cmd, expectedResponse) :
since |
1.5 |
---|
Arguments
- cmd
string
Command to send to the FTP server- expectedResponse
mixed
Integer response code or array of integer response codes
Response
bool
True if command executed successfully
_verifyResponse
Verify the response code from the server and log response if flag is set
_verifyResponse( expected) :
since |
1.5 |
---|
Arguments
- expected
mixed
Integer response code or array of integer response codes
Response
bool
True if response code from the server is expected
append
Method to append a string to the FTP server
append( remote, buffer) :
since |
3.6.0 |
---|
Arguments
- remote
string
FTP path to file to append to- buffer
string
Contents to append to the FTP server
Response
bool
True if successful
chdir
Method to change the current working directory on the FTP server
chdir( path) :
since |
1.5 |
---|
Arguments
- path
string
Path to change into on the server
Response
bool
True if successful
chmod
Method to change mode for a path on the FTP server
chmod( path, mode) :
since |
1.5 |
---|
Arguments
- path
string
Path to change mode on- mode
mixed
Octal value to change mode to, e.g. '0777', 0777 or 511 (string or integer)
Response
bool
True if successful
connect
Method to connect to a FTP server
connect( host = '127.0.0.1', port = 21) :
since |
3.0.0 |
---|
Arguments
- host
string
Host to connect to [Default: 127.0.0.1]- port
int
Port to connect on [Default: port 21]
Response
bool
True if successful
create
Method to create an empty file on the FTP server
create( path) :
since |
1.5 |
---|
Arguments
- path
string
Path local file to store on the FTP server
Response
bool
True if successful
delete
Method to delete a path [file/folder] on the FTP server
delete( path) :
since |
1.5 |
---|
Arguments
- path
string
Path to delete
Response
bool
True if successful
get
Method to get a file from the FTP server and save it to a local file
get( local, remote) :
since |
1.5 |
---|
Arguments
- local
string
Local path to save remote file to- remote
string
Path to remote file to get on the FTP server
Response
bool
True if successful
getInstance
Returns the global FTP connector object, only creating it if it doesn't already exist.
getInstance( host = '127.0.0.1', port = '21', mixed||string|int options = [], user = null, pass = null) : \Joomla\CMS\Client\FtpClient
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 |
1.5 |
---|
Arguments
- host
string
Host to connect to- port
string
Port to connect to- options
array<string|int, mixed>
Array with any of these options: type=>[FTP_AUTOASCII|FTP_ASCII|FTP_BINARY], timeout=>(int)- user
string
Username to use for a connection- pass
string
Password to use for a connection
Response
FtpClient
The FTP Client object.
isConnected
Method to determine if the object is connected to an FTP server
isConnected() :
since |
1.5 |
---|
Response
bool
True if connected
listDetails
Method to list the contents of a directory on the FTP server
listDetails( path = null, type = 'all') :
since |
1.5 |
---|
Arguments
- path
string
Path to the local file to be stored on the FTP server- type
string
Return type [raw|all|folders|files]
Response
mixed
If $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( path = null) :
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 |
1.5 |
---|
Arguments
- path
string
Path local file to store on the FTP server
Response
string
Directory listing
login
Method to login to a server once connected
login( user = 'anonymous', pass = '[email protected]') :
since |
1.5 |
---|
Arguments
- user
string
Username to login to the server- pass
string
Password to login to the server
Response
bool
True if successful
mkdir
Method to create a directory on the FTP server
mkdir( path) :
since |
1.5 |
---|
Arguments
- path
string
Directory to create
Response
bool
True if successful
pwd
Method to retrieve the current working directory on the FTP server
pwd() :
since |
1.5 |
---|
Response
string
Current working directory
quit
Method to quit and close the connection
quit() :
since |
1.5 |
---|
Response
bool
True if successful
read
Method to read a file from the FTP server's contents into a buffer
read( remote, &buffer) :
since |
1.5 |
---|
Arguments
- remote
string
Path to remote file to read on the FTP server- buffer
string
Buffer variable to read file contents into
Response
bool
True if successful
reinit
Method to reinitialise the server, ie. need to login again
reinit() :
NOTE: This command not available on all servers
since |
1.5 |
---|
Response
bool
True if successful
rename
Method to rename a file/folder on the FTP server
rename( from, to) :
since |
1.5 |
---|
Arguments
- from
string
Path to change file/folder from- to
string
Path to change file/folder to
Response
bool
True if successful
restart
Method to restart data transfer at a given byte
restart( point) :
since |
1.5 |
---|
Arguments
- point
int
Byte to restart transfer at
Response
bool
True if successful
setOptions
Set client options
setOptions(mixed||string|int options) :
since |
1.5 |
---|
Arguments
- options
array<string|int, mixed>
Associative array of options to set
Response
bool
True if successful
size
Get the size of the remote file.
size( remote) :
since |
3.6.0 |
---|
Arguments
- remote
string
FTP path to file whose size to get
Response
mixed
number of bytes or false on error
store
Method to store a file to the FTP server
store( local, remote = null) :
since |
1.5 |
---|
Arguments
- local
string
Path to local file to store on the FTP server- remote
string
FTP path to file to create
Response
bool
True if successful
syst
Method to system string from the FTP server
syst() :
since |
1.5 |
---|
Response
string
System identifier string
write
Method to write a string to the FTP server
write( remote, buffer) :
since |
1.5 |
---|
Arguments
- remote
string
FTP path to file to write to- buffer
string
Contents to write to the FTP server
Response
bool
True if successful
Properties
_responseCode
The response code
since |
4.3.0 |
---|
Type(s)
string
_responseMsg
The response message
since |
4.3.0 |
---|
Type(s)
string
_conn
Socket resource
since |
1.5 |
---|
Type(s)
resource
_dataconn
Data port connection resource
since |
1.5 |
---|
Type(s)
resource
_pasv
Passive connection information
since |
1.5 |
---|
Type(s)
array<string|int, mixed>
_response
Response Message
since |
1.5 |
---|
Type(s)
string
_timeout
Timeout limit
since |
1.5 |
---|
Type(s)
int
_type
Transfer Type
since |
1.5 |
---|
Type(s)
int
_autoAscii
Array to hold ascii format file extensions
since |
1.5 |
---|
Type(s)
array<string|int, mixed>
_lineEndings
Array to hold native line ending characters
since |
1.5 |
---|
Type(s)
array<string|int, mixed>
instances
FtpClient instances container.
since |
2.5 |
---|
Type(s)
array<string|int, mixed>