Page 1 of 1

Copy folders and files from one remote server to another

Posted: Mon Jun 14, 2010 12:54 am
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

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

Posted: Mon Jun 14, 2010 1:42 am
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?

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

Posted: Tue Jun 15, 2010 1:51 am
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