Copy directory to another on site

1

I have a website in PHP and JavaScript. I set a button with the following function (found on the internet, called wrench.copyDirSyncRecursive ):

function atualizaIR(){
    dir1 = '201.7.201.173/Documentos/Teste1';
    dir2 = '201.7.201.173/Documentos/Teste2';
    wrench.copyDirSyncRecursive(dir1,dir2);
    alert('IRs atualizados!');
}

Since the function (which is linked to a button I created on the page) should copy the entire contents of the Teste1 directory to the Teste2 directory.

I know there are several ways to do this file copy, but I have not yet managed the most efficient one that works for my client's site. In addition, the dir1 folder can be on a hard disk C of the machine with this IP, while the dir2 folder can be on a hard disk D, on the machine of that same IP.

Is it very difficult to do?

editing

I did as follows. In the JS file, it has this function:

function atualizaIR(){
$.ajax({
      async: true, 
      cache:false, 
      url: '[:raiz]consultaRendimentos/atualizaIR',
      dataType: 'json',      
      type: 'POST',
      success: function(data) {
          alert('IRs atualizados!');
      }
});
}

And in the Controller file, I did the following (based on w3schols.com):

public function atualizaIR(){
    // connect and login to FTP server
    $ftp_server = "http://201.7.201.173/";
    $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
    $login = ftp_login($ftp_conn, $ftp_user, $ftp_password);

    $local_file = '../Documentos/Teste1/';
    $server_file = '../Documentos/Teste2/';

    // initiate download
    $d = ftp_nb_get($ftp_conn, $local_file, $server_file, FTP_ASCII);

    do{
        // do whatever you want
        // continue downloading
        $d = ftp_nb_continue($ftp_conn);
    }while ($d == FTP_MOREDATA);

    if ($d != FTP_FINISHED)
    {
        echo "Error downloading $server_file";
        exit(1);
    }

    // close connection
    ftp_close($ftp_conn);
}

But it did not work. Inside my server, I did not copy the files from Test2 to Test1 or vice versa. I must be forgetting too much for this file copy to happen.

    
asked by anonymous 23.04.2015 / 20:34

0 answers