Simple PHP FTP client
Connect and Log in to Server :
// connect to ftp server
$ftp = new FtpClient();
$ftp->connect($host, $ssl, $port, $timeout);
$ftp->login($login, $password);
OR
Connect to a server FTP via SSL (on port 22 or another port) :
// connect to ftp server
$ftp = new FtpClient();
$ftp->connect($host, true, 22, $timeout);
$ftp->login($login, $password);
Upload all files and all directories is easy :
// upload with the BINARY mode
$ftp->put($local_file, $remote_file);
// Is equal to
$ftp->put($local_file, $remote_file, FTP_BINARY);
// or upload with the ASCII mode
$ftp->put($local_file, $remote_file, FTP_ASCII);
// This uses passive mode
$ftp->passive();
// If you want to disable using passive mode then
$ftp->passive(false);
// Returns a list of files
$ftp->listItem();
// Returns a list of directories
$ftp->listItem(true);
// Returns a list of files in the given directory
$ftp->listItem(false, 'path/of/directory');
// Returns all files within folder and subfolders ignore *.zip files
$ftp->listItem(false, 'path/of/directory', true, array('zip'));
$ftp->exec($command);
// download with the BINARY mode
$ftp->get($remote_file, $local_file);
// Is equal to
$ftp->get($remote_file, $local_file, FTP_BINARY);
// download with the ASCII mode
$ftp->get($remote_file, $local_file, FTP_ASCII);
// Returns a list of files in the given directory
$ftp->nList('path/of/directory/to/create');
// Creates a directory
$ftp->mkdir('path/of/directory/to/create');
// Get last modified time to file
$ftp->getLastMod('file.php');
// Set permissions on a file via FTP
$ftp->chmod(0777, 'file.php');
// Get file size
$ftp->getSize('file.php');
// Get current directory
$ftp->pwd();
// Delete file on FTP server
$ftp->delete('file.php');
//and more...
See the source code for more details. It is fully documented 📘
MIT c) 2018, Zakharov Andrew https://github.com/ZakharovAndrew.