簡體   English   中英

ssh2_scp_send()和ssh2_scp_recv()函數在php中不起作用。 為什么?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM