FTPManager

Extends\org\turbocommons\src\main\php\model\BaseStrictClass

A Synchronous class to manage and operate with ftp connections

package

Default

Methods

Initialize a new connection to the specified remote FTP location

__construct(string $userName,string $psw,string $host,integer $port = null,integer $timeout = 90)
Throws
\UnexpectedValueException

If connection cannot be established

Arguments

$userName

string

The username for the ftp session we want to start

$psw

string

The password for the ftp user

$host

string

The FTP server address. This parameter shouldn't have any trailing slashes and shouldn't be prefixed with ftp://.

$port

integer

This parameter specifies an alternate port to connect to. If it is omitted or set to zero, then the default FTP port, 21, will be used.

$timeout

integer

This parameter specifies the timeout for all subsequent network operations. If omitted, the default value is 90 seconds. The timeout can be changed and queried at any time

Ftp destructor will always close the current connection to avoid problems with opened connections.

__destruct()
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Protection to prevent accessing undefined properties to this class

__get(string $name): void
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$name

string

The property name

Protection to prevent creating extra properties to this class

__set(string $name,string $value): void
inherited
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$name

string

The property name

$value

string

The property value

Terminate the current FTP connection

closeConnection(): void
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Get a file from an ftp path and store it directly to the specified file path (If the specified file exists, will be overriden).

downloadFile(string $ftpPath,string $localPath): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$ftpPath

string

The file full ftp path including the file name

$localPath

string

The local path where the file will be stored, including the filename where the data will be saved.

Response

boolean

True on sucess or false if the download fails

Gives the list of items that are stored on the specified ftp folder. It will give files and directories, and each element will be the item name, without the path to it.

getDirectoryList(string $path = '/'): array

The contents of any subfolder will not be listed. We must call this method for each child folder if we want to get it's list.

Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$path

string

Full path to the directory we want to list. Example: 'folder/' by default the root ftp folder is used ('/')

Response

array

The list of item names inside the specified path

Read and return an ftp file contents. Remember that big files may become problematic as we are only using memory to read the file data, the file is not stored no disk.

readFile(string $ftpPath): string
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$ftpPath

string

The file full ftp path including the file name

Response

string

The file binary information

Create a file to the specified ftp path and write the specified data to it.

saveFile(string $pathToFtpFile,string $data = ''): boolean
Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar://D:/Storage/Git/TurboBuilder/TurboBuilder-Node/src/main/libs/phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Arguments

$pathToFtpFile

string

The full ftp path where the file will be stored, including the full file name

$data

string

Information to store on the file (a string, a block of bytes, etc...)

Response

boolean

Returns true on success or false on failure.

Properties

Variable that contains the last error that happened (if any).

lastError :

Type(s)

Define the type of data transfer for the ftp connection: FTP_BINARY (default and recommended) or FTP_ASCII

transferMode :

Type(s)