PHP code example of damijanc / simple-ftp

1. Go to this page and download the library: Download damijanc/simple-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/ */

    

damijanc / simple-ftp example snippets


$conn = ftp_connect($host, $port, $timeout);
if ($conn) {
  $login_result = ftp_login($conn, $user, $password);
  if ($login_result) {
          $connected = TRUE;
  }
}

use damijanc\FTP\Client;

$ftp = new Client($options);
$ftp->connect();


use damijanc\FTP\Client;

$options = array;
$options['server'] = 'ftp.example.com';
$options['port'] = 21;
$options['user'] = 'user';
$options['pass'] = 'password';

//connect to server
$ftp = new Client($options);
$ftp->connect();
//got to folder
$ftp->cd('Folder1');
//upload file
$ftp->put('file1.zip');
//list content
$ftp->ls();
//end session
$ftp->disconnect();