Copy files server to server


When I am new in buy and sell web site business my biggest problem is transfering the content of my site from my server to my customer server.

May be you’re thinking that is not really a problem, you need only to download the site content then upload them to other server. Yes that what I did before, but don’t you think the time you will consume downloading 500 MB or higher content of site in to your computer then upload it again to other server?

So I decided to make some research and make expirement until I come up with a script that I can use as my personal file transfer script.

You can get this script and use for your personal use and hope it will works with you too.

<?php
set_time_limit(0);
$HOST=”"; //eg tips1001.com
$UN=”"; //your user name
$PW=”"; // your password
$DIR=”"; //directory where to copy

$conn = ftp_connect($HOST);
if(!$conn) {
exit(”Could not connect to server: $HOST\n”);
}else{
echo “connected <p>”;
}

if(!ftp_login($conn,$UN,$PW)) {

ftp_quit($conn);
exit(”Could not log in\n”);
}

ftp_chdir($conn,$DIR);

echo “<p>Current directory is ” .ftp_pwd($conn);

$files = ftp_nlist($conn,”.”);

for($i=0;$i<count($files);$i++) {
echo “Saving $files[$i] <br>”;

if(!ftp_get($conn,$files[$i],$files[$i],FTP_BINARY)) {
echo “Could not download {$files[$i]}\n”;
}
}

ftp_quit($conn);
?>

You must be logged in to post a comment.