Nice and Easy Reverse FTP transfer


After spending countless hours to complete a new web project for your client, your PHPs are lined up and FileZilla is ready for action. The most shocking moment would be finding your client’s ISP offers only a low-end File Manager. Oh boy! just WordPress 3.1.0 alone equals to 82 folders and 835 files nowadays.


How about a reverse FTP transfer process and have the web server come to you for the files? We found some scripts from the Binary Taskforce web team development toolbox that may help. Read on…

Typical FTP

A Typical FTP transfer can be described as follows:

A hosting (Web Server) is equipped with a running FTP service. When a FTP client (Workstation, You) connects to the FTP server and upon successful authentication, new files (i.e. Web content) are uploaded to the server. Once upload is finished, the client disconnects and FTP process is ended.

Reverse FTP

A Reverse FTP transfer is slightly different:

Since there is no running FTP server on the host (Web Server), we need to utilize the PHP scripting language’s FTP function to initiate the transfer of files. The (Workstation, You) now needs FTP server to serve the content you wanted to upload. Calling the PHP script will cause the host (Web Server) to establish a FTP connection and get the files from you. Once it has everything, Web Server disconnects and process is ended.

How is it done?

There are prerequisites in order to get this to work. First, your ISP host (Web Server) must support PHP scripting language and its FTP extension is enabled. You can confirm yours by using phpinfo(). Your local workstation needs FTP server, this can be easily achieved by installing FileZilla FTP server software.

Step 1 – Prepare the manifest

On your local workstation, assuming you have all files ready in a folder. We will run the manifest.php script against this folder, upon completion you will find two files, named Directories.txt and Files.txt respectively.

$ManifestFileOutput = "Files.txt"; //Manifest Output for files
$ManifestDirectoryOutput = "Directories.txt"; //Manifest Output for directories
$SourceFolder = "wordpress"; //Folder to be scanned
$RunMode = 1; //RunMode, 0=Dry run 1=Live
Step 2 – Upload Manifests and Scripts on to web server

Use the file management tool provided by your ISP to upload the two files (Directories.txt and Files.txt) along with two scripts (setupdir.php and setupfile.php) to the root folder of your webserver.

Step 3 – Calling setupdir.php and setupfile.php from browser

With four files uploaded to your webserver. First call setupdir.php (i.e., it reads the directories.txt file and create the folder structure specified.

$SourceFile = "Directories.txt"; // The script will look for this file
$SecuritySettings = 0755; //File Permission given to newly created directory
$RunMode = 1; // RunMode, 0=Dry run vs. 1=Live Run

Next, configure and call setupfile.php (i.e., this is where the reverse FTP process begins. The script reads files.txt, establishes FTP connection to your local workstation, retrieves the needed files and stores them in the respective locations.

$ftp_server = ""; // Local Workstation address
$ftp_user_name = "user"; // FTP user name
$ftp_user_pass = "password"; // FTP user password
$SecuritySettings = 0644; // File Permission after transferred
$RunMode = 1; // RunMode, 0=Dry run vs. 1=Live Run

Easy as 1-2-3

Download the files

All of them in a zip []
MD5 Checksum: 8e2d71bae105d89d00a1da3578c461c8
Size: 8440 bytes

Feel free to modify the script to your needs, hope this article will help out some DIY newbie developers and webmasters. Don’t hesitate to comment and provide your feedback.

Enjoy, Team BTF

Leave a Reply

Your email address will not be published. Required fields are marked *