PHP Server to Server Transfer Script to Remotely Transfer Files

While Switching Web Hosts, we need to download all our files from the old server and then upload them to the new server. It will not be a problem for ones who only have few MB’s to transfer or ones who have high speed connections which can do the download and upload in minutes. But, if the size of files is Huge and the connection is of average speed, it can consume too much of time. Here, Server to Server Transfer Script comes for the rescue.

Server to Server transfer script allows you to download files from another Server and save it locally on the required server. What the script does is to Fetch the file from the URL provided and then saves it to the local server space. It uses the bandwidth and high speed connection of the server and hence the transfer completes in few minutes without much hassle. Here’s how to use it:

  1. Create a new directory named sst (or anything you wish) on the server on which you wish to transfer the files.
  2. Create a new File named sst.php in the folder created in previous step and paste the following script in it and save the file:
        <form method="post">
        <input name="url" size="50" />
        <input name="submit" type="submit" />
        // maximum execution time in seconds
        set_time_limit (24 * 60 * 60);
        if (!isset($_POST['submit'])) die();
        // folder to save downloaded files to. must end with slash
        $destination_folder = 'downloads/';
        $url = $_POST['url'];
        $newfname = $destination_folder . basename($url);
        $file = fopen ($url, "rb");
        if ($file) {
          $newf = fopen ($newfname, "wb");
          if ($newf)
          while(!feof($file)) {
            fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
        if ($file) {
        if ($newf) {
  3. Create a new sub-directory named downloads in the directory created in first step.
  4. Now, just open the sst.php in a web browser by pointing your browser to –
  5. If you pointed to the correct URL, a form will open up. Just enter the URL of the file which you wish to download to the server and press Enter.
  6. If everything goes correctly, file will be downloaded and saved in the /sst/downloads/ directory.
Join over 3.000 visitors who are receiving our newsletter and stay updated about what is happening in the tech world.
We hate spam. Your email address will not be sold or shared with anyone else.


5 Responses to PHP Server to Server Transfer Script to Remotely Transfer Files

  1. Pradeep July 12, 2015 at 1:22 am #

    Thanks for the great script!…. transferred a 2gb zip file within few mins….

    • Narender Singh July 12, 2015 at 1:31 am #

      Wonderful that is. I remember the day when I had a poor connection and was required to transfer all data from one Web hosting to another. This script saved my life. Glad that it helped you too 🙂

  2. Saurabh January 15, 2016 at 8:51 am #

    Not Working ….

    Don’t Show any Error ..

    • Narender Singh January 15, 2016 at 10:03 am #

      Did you check the error log?

  3. Hassan Imtiaz January 9, 2017 at 5:36 pm #

    Great script! Just what I was looking for. However, I have a question, is there a way to remove some of the text from file name? For example, if the original file name is “” and when it is transferred to the destination folder, the text “file” gets removed from the name and the output would be just “”. Thanks!

Leave a Reply