I just released two new libraries for such things in FTP and SFTP .
Recursively copying files and folders to a remote SFTP server (if local_path ends with the contents of a slash folder, otherwise the folder itself is loaded)
Ftp::upload_dir($server, $user, $password, $local_path, $remote_path, $port = 22);
Downloading the directory from a remote FTP server (if remote_dir ends with the contents of the slash folder, otherwise the folder itself is loaded)
Ftp::download_dir($server, $user, $password, $remote_dir, $local_dir, $port = 22);
This is true for the code here, but you will need the entire class for the dependencies of small utilities.
public static function download_dir($server, $user, $password, $remote_dir, $local_dir, $port = 21) { $downloaded = false; try { if(is_dir($local_dir) && is_writable($local_dir)) { if(false !== $cid = Ftp::login($server, $user, $password, $port)) {
source share