Functions
Function | Description |
---|---|
changeToParentDirectory |
Changes the current working directory to its parent. |
changeDirectory |
Changes the current working directory to given path. |
connect |
Connects to a server. |
createDirectory |
Creates a directory. |
deleteDirectory |
Deletes a given directory (it must be empty to be deleted). |
deleteFile |
Deletes a given directory (it must be empty to be deleted). |
disconnect |
Closes the FTP connection. |
downloadFile |
Downloads a file from the FTP server. |
getCurrentDirectory |
Returns the name of the current working directory. |
getDirectoryContents |
Returns parsed directory information. |
getRawDirectoryContents |
Calls a direct LIST command to the FTP server and returns the results. |
getSystemType |
Returns the system type of the FTP server. |
login |
Login to the FTP host. |
parseListing |
Parses a line from the FTP LIST response into an array of information. |
rename |
Renames a file or directory. |
setTransferType |
Sets the transfer type. |
uploadFile |
Uploads a file to the FTP server. |
changeToParentDirectory
Changes the current working directory to its parent.
Return Value: true if successful
changeToParentDirectory()
changeDirectory
Changes the current working directory to given path.
Return Value: true if successful
changeDirectory($path)
Parameter | Description |
---|---|
$path |
Full directory path to change to. |
connect
Connects to a server.
Return Value: true if successful
connect($host, $port = 21)
Parameter | Description |
---|---|
$host |
The hostname of the server |
$port |
The port to connect to (defaults to 21) |
createDirectory
Creates a directory.
Return Value: true if successful.
createDirectory($path)
Parameter | Description |
---|---|
$path |
Full directory path to create or a path relative to the current directory. |
deleteDirectory
Deletes a given directory (it must be empty to be deleted).
Return Value: true if successful
deleteDirectory($path)
Parameter | Description |
---|---|
$path |
The full directory path or relative to the current directory. |
deleteFile
Deletes a given directory (it must be empty to be deleted).
Return Value: true if successful
deleteFile($path)
Parameter | Description |
---|---|
$path |
The full file path or path relative to the current directory. |
disconnect
Closes the FTP connection.
disconnect()
downloadFile
Downloads a file from the FTP server.
Return Value: true if successful.
downloadFile($remote, $local)
Parameter | Description |
---|---|
$remote |
The full path to the file to download (or the path relative to the current directory). |
$local |
The local path to store the downloaded file. |
getCurrentDirectory
Returns the name of the current working directory.
Return Value: The current working directory or false if the call failed.
getCurrentDirectory()
getDirectoryContents
Returns parsed directory information.
Return Value: An array of parsed information.
getDirectoryContents($path = "")
Parameter | Description |
---|---|
$path |
Optional directory to search, otherwises uses the current directory. |
getRawDirectoryContents
Calls a direct LIST command to the FTP server and returns the results.
Return Value: An array of information from the FTP LIST command.
getRawDirectoryContents($path = "")
Parameter | Description |
---|---|
$path |
Optional directory to search, otherwises uses the current directory. |
getSystemType
Returns the system type of the FTP server.
Return Value: An array of system information.
getSystemType()
login
Login to the FTP host.
Return Value: true if successful
login($user = null, $pass = null)
Parameter | Description |
---|---|
$user |
FTP username (or null to login anonymously). |
$pass |
FTP password (or null to login anonymously). |
parseListing
Parses a line from the FTP LIST response into an array of information.
Return Value: An array of information or false if the line was corrupt.
parseListing($list)
Parameter | Description |
---|---|
$list |
A line from an FTP listing. |
rename
Renames a file or directory.
Return Value: true if successful
rename($from, $to)
Parameter | Description |
---|---|
$from |
The current file/directory name (either absolute path or relative to current directory). |
$to |
The new file/directory name (either absolute path or relative to current directory). |
setTransferType
Sets the transfer type.
setTransferType($type)
Parameter | Description |
---|---|
$type |
AUTOASCII (-1), ASCII (0), BINARY (1) |
uploadFile
Uploads a file to the FTP server.
Return Value: true if successful
uploadFile($local, $remote)
Parameter | Description |
---|---|
$local |
The full path to the file to upload. |
$remote |
The full path to store the file at (or relative path to the current directory). |