Feasible web development curl FTP provides a client based on Curl.
$ composer require fewedev/curl-ftpFeasible web development curl FTP is licensed under the MIT License - see the LICENSE file for details.
$ftp = new Client();
$ftp->open([
'host' => 'ftp.example.com',
'user' => 'username',
'password' => 'password',
'port' => 990,
'ssl' => true,
'passive' => true,
'timeout' => 30
]);Alternatively you can create a connection using the connect() method
$ftp->connect($hostName, $port, $userName, $password, $useSsl, $usePassiveMode, $timeout);$files = $ftp->ls();
print_r($files);produces
Array
(
[0] => Array
(
[text] => file_1.zip
[id] => /file_1.zip
)
[1] => Array
(
[text] => file_2.zip
[id] => /file_2.zip
)
)
$ftp->cd('directory/subdirectory');$contents = $ftp->read('path/to/file.zip');$contents = 'file contents';
$ftp->write('path/to/file.txt', $contents);$ftp->rm('path/to/file.txt');All exceptions are thrown as standard Exception classes with the following message format:
Could not handle content in path: {path} ({cURL error number})