0

I have a lengthy PHP script that takes a form, outputs it as a csv file, uploads it to a remote server and then moves it to another directory on the server. Everything is working except for moving it to a remote folder after upload. Here is what I have:

    $connection = ssh2_connect('server.url', 22);
    ssh2_auth_password($connection, 'user', 'pwd');
    ssh2_scp_send($connection, '/var/app/current/Folder/LocalFolder/File.csv', '/home/user/RemoteFolder1/File.csv', 0644);

    //here is where I am stuck
    mv /home/user/RemoteFolder1/File.csv /home/user/RemoteFolder2/File.csv

    //I think this exits sufficiently, is there a better way
    ssh2_exec($connection, 'exit');
    unset($connection);

Why do I need to move it and not just upload it into the second folder?Same question I asked. From remote server's admin 'it is easy for there to be a race condition where we will read a file while you are uploading the file. This will result in use receiving only part of the file.' they need it to completely upload, then move to the second folder How do I move it from RemoteFolder1 to RemoteFolder2? I dont know the correct command, so far mv and move_uploaded_file have not worked

Dirty Bird Design
  • 5,333
  • 13
  • 64
  • 121

0 Answers0