PHP ssh2_scp_send fails to send files as intended

Asked 1 years ago, Updated 1 years ago, 447 views

$remote_path is recognized as a filename, not a directory name.
If you know how to send files to the specified directory, please contact us.

(Example) Files such as \home\user\test.csv are created.
   test.csv is not sent to the directory \home\user.

if(!ssh2_scp_send($connection,$local_path.$fileName,$remote_path.$fileName,0644)){
    // error handling
}

Environment: xampp + PHP 7.1

php cakephp scp

2022-12-21 22:07

1 Answers

The third argument of ssh2_scp_send is always the path of the file (not the directory).

reference:
ssh2_scp_send-PHP Manual

 ssh2_scp_send(
    resource$session,
    string$local_file,
    string$remote_file,
    int$create_mode=0644
) :bool
  • remote_file
    Path to the remote file.


2022-12-22 08:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.