PHP code example of php-core / sftp

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

    

php-core / sftp example snippets



use PHPCore\SFTP\SFTP;

SFTP::test($server, $user, $password, $port = 22, $timeout = 10);

SFTP::isFile($server, $user, $password, $remoteFile, $port = 22, $timeout = 10);

SFTP::delete($server, $user, $password, $remoteFile, $port = 22, $timeout = 10);

SFTP::rmdir($server, $user, $password, $remotePath, $port = 22, $timeout = 10);

SFTP::uploadDir($server, $user, $password, $localPath, $remotePath, $port = 22, $timeout = 10);

SFTP::download($server, $user, $password, $remoteFile, $localFile, $port = 22, $timeout = 10);

SFTP::downloadDir($server, $user, $password, $remoteDir, $localDir, 
$port = 22, $timeout = 10);

SFTP::rename($server, $user, $password, $oldFile, $newFile, $port = 22, $timeout = 10);

SFTP::mkdir($server, $user, $password, $directory, $port = 22, $timeout = 10);

SFTP::touch($server, $user, $password, $remoteFile, $content, $port = 22, $timeout = 10);

SFTP::upload($server, $user, $password, $localFile, $remoteFile = '', $port = 22, $timeout = 10);

SFTP::scandir($server, $user, $password, $path, $port = 22, $timeout = 10);

SFTP::pwd($server, $user, $password, $port = 22, $timeout = 10);

php example/test.php