Copy folders and files from one remote server to another

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rachelk
Forum Newbie
Posts: 2
Joined: Mon Jun 14, 2010 12:49 am

Copy folders and files from one remote server to another

Post by rachelk »

Hii

Can you please help me out for copying folders and files from one remote server to another remote server in PHP?
I need the PHP script.
Waiting for your reply

Thanks ,
Rachel
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Copy folders and files from one remote server to another

Post by requinix »

Yeah... Saying "I need the script" kinda implies that you're waiting for us to do the work. That's not how it goes.
We'll offer advice, suggestions, comments on a design you've come up with or code you've imagined, but we won't do it for you.

On that note,
Are you able to SSH into both of the remote machines?
rachelk
Forum Newbie
Posts: 2
Joined: Mon Jun 14, 2010 12:49 am

Re: Copy folders and files from one remote server to another

Post by rachelk »

tasairis wrote:Yeah... Saying "I need the script" kinda implies that you're waiting for us to do the work. That's not how it goes.
We'll offer advice, suggestions, comments on a design you've come up with or code you've imagined, but we won't do it for you.

On that note,
Are you able to SSH into both of the remote machines?

Hi i have the code here
$dst_dir = "/mnt/httpd/vhosts/pmstestdomain.com/test/"; //for example absolute path i gave in this way
$src_dir = "--------";

function ftp_copyAll($conn_id, $src_dir, $dst_dir) {
if(is_dir($dst_dir)){
return "<br> Dir <b> $dst_dir </b> Already exists <br> ";
}else{
$d = dir($src_dir); // unable to read this absolute path - query fails here
ftp_mkdir($conn_id, $dst_dir); echo "creat dir <b><u> $dst_dir </u></b><br>";
while($file = $d->read()) {
if ($file != "." && $file != "..") {
if (is_dir($src_dir."/".$file)) {
ftp_copyAll($conn_id, $src_dir."/".$file, $dst_dir."/".$file);
} else {
$upload = ftp_put($conn_id, $dst_dir."/".$file, $src_dir."/".$file, FTP_BINARY);
echo "creat files::: <b><u>".$dst_dir."/".$file ." </u></b><br>";
}
}
ob_flush() ;
sleep(1);
}
$d->close();
}
return "<br><br><font size=3><b>All Copied ok </b></font>";
}

Pls help me.hope u understood the code.FTP login and FTP connection are connected when i give the details
Post Reply