How to Upload and Download Entire Directories via FTP in PHP?

View QuestionsCategory: QuestionsHow to Upload and Download Entire Directories via FTP in PHP?
admin Staff asked 7 years ago

How do I do that? PHP functions only allow donwloading files individually.

1 Answers
Best Answer
admin Staff answered 7 years ago

Solution 1
Currently, available PHP code that claim to be able to do this: https://github.com/hugsbrugs/php-ftp From here: https://stackoverflow.com/questions/7892579/php-ftp-library-function-to-download-whole-directory-and-sub-directories-to-loca

Recursively copy files and folders on remote SFTP server 
(If local_path ends with a slash upload folder content otherwise upload folder itself) 
Ftp::upload_dir($server, $user, $password, $local_path, $remote_path, $port = 22); 
Download a directory from remote FTP server (If remote_dir ends with a slash download folder content otherwise download folder itself) 
Ftp::download_dir($server, $user, $password, $remote_dir, $local_dir, $port = 22);

Solution 2
We found a script and posted here:
FTP Class for Recursive Upload and Download Files and Folders via FTP