Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
`ssh2_scp_recv` and `ssh2_scp_send` always returning the following error:

Severity: Warning
Message: ssh2_scp_send(): Failure creating remote file: Unexpected channel close

Severity: Warning
Message: ssh2_scp_recv(): Unable to receive remote file



When I connect to my Windows sftp file server OpenSSH for windows 7.3p1-1
the client also a windows php iis environment with php ssh2 0.12 x64 for windows

PHP
$connection = ssh2_connect("myserver.com", 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection);


$sftp_send = ssh2_scp_send($connection, "$_upload_path"."myfile", "$_remote_folder_path/myfile", 0644 );


$handle = opendir("ssh2.sftp://{$sftp}{$_remote_folder_path}");
 while (false != ($entry = readdir($handle))){

  if ($entry == "." || $entry == "..")
      continue;
   echo $entry;

 $sftp_recv = ssh2_scp_recv ($connection,  $_remote_folder_path."/".$entry , $_download_path.$entry );
}


What I have tried:

both can't send and receive file, but can opendir() on remote folder
fopen also work
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900