Php ssh2\u scp\u发送第一次正常,但第二次失败

Php ssh2\u scp\u发送第一次正常,但第二次失败,php,ssh,scp,Php,Ssh,Scp,我正在使用php ssh2_scp_send将文件传输到远程机器,但这有点奇怪,它第一次工作,但第二次调用失败,出现以下错误 //success for file transfer if (!(ssh2_scp_send($this->conn, $lpath, $rpath, 0777))){ throw new Exception("File transfer failed!"); } ssh2_exec($this->co

我正在使用php ssh2_scp_send将文件传输到远程机器,但这有点奇怪,它第一次工作,但第二次调用失败,出现以下错误

//success for file transfer
if (!(ssh2_scp_send($this->conn, $lpath, $rpath, 0777))){
            throw new Exception("File transfer failed!");
        }
        ssh2_exec($this->conn, 'exit'); 

//fail this time
if (!(ssh2_scp_send($this->conn, $lpath, $rpath, 0777))){
            throw new Exception("File transfer failed!");
        }
        ssh2_exec($this->conn, 'exit')
“警告:ssh2\u scp\u send():在第57行的/var/www/trunk/rsetting/class/ssh.class.php中复制文件失败”


任何帮助都将不胜感激~谢谢

将php-ssh2扩展更新为0.13即可。

我遇到了同样的问题,但通过调用此函数解决了它:

ssh2_exec($conn,'exit')

在循环的末尾。
我认为此命令会刷新缓冲区并正确写入最后一个远程文件。

因为您在第一次传输后已关闭了上的连接<代码>ssh2_exec($this->conn,“exit”)谢谢你的评论,我已经删除了代码,但问题仍然存在:(是的,完全相同的错误