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:
- Create a new directory named sst (or anything you wish) on the server on which you wish to transfer the files.
- 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:
<html> <form method="post"> <input name="url" size="50" /> <input name="submit" type="submit" /> </form> <?php // 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) { fclose($file); } if ($newf) { fclose($newf); } ?> </html>
- Create a new sub-directory named downloads in the directory created in first step.
- Now, just open the sst.php in a web browser by pointing your browser to – http://YourDomain.com/sst/sst.php
- 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.
- If everything goes correctly, file will be downloaded and saved in the /sst/downloads/ directory.
Hi is there any way to a loading bar? Many thanks
Hi, this wasn’t coded by me and is only shared here. So, I am not the right person to enhance it.
What I usually do in case of large files is to look at the directory where the file is being saved. Every refresh will update the size of the file as it keeps getting written. So, that’s how I figure out how far it has reached.
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 “example-file.zip” and when it is transferred to the destination folder, the text “file” gets removed from the name and the output would be just “example.zip”. Thanks!
Not Working ….
Don’t Show any Error ..
Did you check the error log?
Thanks for the great script!…. transferred a 2gb zip file within few mins….
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 🙂