PHP code example of idct / sftp-client

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

    

idct / sftp-client example snippets




composer 



use IDCT\Networking\Ssh\SftpClient;
use IDCT\Networking\Ssh\Credentials;

$client = new SftpClient();

$credentials = Credentials::withPassword($username, $password);
$client->setCredentials($credentials);

$credentials = Credentials::withPublicKey($username, $publicKey, $privateKey, $passphrase = null);
$client->setCredentials($credentials);

$client->connect($host);

$client->download(ENTER_REMOTE_FILE_NAME);
$client->download(ENTER_REMOTE_FILE_NAME, ENTER_LOCAL_FILE_NAME);

$client->upload(ENTER_LOCAL_FILE_NAME);
$client->upload(ENTER_LOCAL_FILE_NAME, ENTER_REMOTE_FILE_NAME);

$client->scpDownload(ENTER_REMOTE_FILE_NAME);

$client->scpUpload(ENTER_LOCAL_FILE_NAME,ENTER_REMOTE_FILE_NAME);

$client->close();