![](/img/trans.png)
[英]Unable to send or receive file using ssh2_scp_recv and ssh2_scp_send
[英]ssh2_scp_send() and ssh2_scp_recv() functions are not working in php. Why?
ssh2_scp_send()函数挂在php中。 这是代码:
$debug_line_feed = "\n";
$conn = ssh2_connect($sftp_server, 22);
$return = ssh2_auth_password($conn, $sftp_user_name, $sftp_user_pass);
if ($return===true) echo "successfull connection".$debug_line_feed;
echo "uploading file".$debug_line_feed;
$local_filename = $product_feed_file_with_path;
$remote_filename = 'product_feed.txt';
ssh2_scp_send($conn, $local_filename, $remote_filename);
echo "successful".$debug_line_feed;
当我运行它时,它输出“成功连接”,然后“正在上传文件”挂起。 任何想法如何解决这个问题?
我也尝试过使用ssh2_scp_recv下载,并且它也挂起,本地文件被创建为0字节文件。
我的猜测是服务器已安装了监狱外壳。 到那时,SCP无效,但SFTP可以。
最近,我使用sftp发送文件,linux到Windows,ssh2_scp_send无法正常工作,我解决了使用问题
$sftp = ssh2_sftp($conn);
$contents = file_get_contents($localPath);
$result = file_put_contents("ssh2.sftp://{$sftp}/{$remotePath}", $contents);
然后工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.