【发布时间】:2022-01-05 15:31:06
【问题描述】:
我正在尝试使用 SFTP 连接从服务器下载文件并将其保存在我的服务器上,但文件为空。
$connection = ssh2_connect('{my server ip}', 22);
ssh2_auth_password($connection, '{user}', '{password}');
$sftp = ssh2_sftp($connection);
$file = "test.txt";
$target_path = "ssh2.sftp://$sftp/public_html/$file";
$stream = fopen($target_path, 'r');
fopen($file, "w");
fclose($stream);
【问题讨论】: