1. Go to this page and download the library: Download lc5/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/ */
lc5 / ftp example snippets
use Lc5\Ftp\Ftp;
try {
$ftp = new Ftp('ftp.example.com', 'username', 'password');
//Save remote.txt to local.txt
$ftp->get('local.txt', 'remote.txt', FTP_ASCII);
//Actually you don't have to explicitly call close()
//It will get called automatically as a part of the __destruct() method
$ftp->close();
//For anonymous login you only need to pass the host address
$ftp = new Ftp('ftp.example.com');
$ftp->pasv(true);
//Get list of files in current directory and print them
$files = $ftp->rawlist('.');
foreach ($files as $file) {
echo $file . PHP_EOL;
}
} catch (\Exception $e) {
echo $e->getMessage();
}
use Lc5\Ftp\Ftp;
class MyFtp extends Ftp
{
public function myFunction()
{
$connection = $this->connect();
//your custom code...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.