PHP code example of ngyuki / php-ftp-client
1. Go to this page and download the library: Download ngyuki/php-ftp-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/ */
ngyuki / php-ftp-client example snippets
ngyuki\FtpClient\FtpClient;
use ngyuki\FtpClient\FtpException;
use ngyuki\FtpClient\TransportException;
$ftp = new FtpClient();
try
{
$ftp->connect("example.net", 21, 10);
$ftp->login("hoge", "piyo");
echo "nlist...\n";
echo implode("\n", $ftp->nlist("."));
echo "\n\n";
echo "put...\n";
$ftp->put("test.txt", "testing");
$ftp->quit();
echo "done.\n";
}
catch (FtpException $ex)
{
echo "FtpException: {$ex->getResponse()->getResponseLine()}\n";
}
catch (TransportException $ex)
{
echo "TransportException: {$ex->getMessage()}\n";
}
console
$ php composer.phar