PHP code example of tofex / curl-ftp

1. Go to this page and download the library: Download tofex/curl-ftp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tofex / curl-ftp example snippets


$ftp = new Client();
$ftp->open([
    'host' => 'ftp.example.com',
    'user' => 'username',
    'password' => 'password',
    'port' => 990,
    'ssl' => true,
    'passive' => true,
    'timeout' => 30
]);

$ftp->connect($hostName, $port, $userName, $password, $useSsl, $usePassiveMode, $timeout);

$files = $ftp->ls();

print_r($files);

$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');