下面是运行了一段时间的代码,本周它停止工作了。我已将其缩小到“fopen”语句失败的那一行。如果我注释掉 fopen 行,我会得到正确的 echo 。起初我以为这是远程服务器上的权限问题,但我在不同的服务器上也发生了同样的事情。
我并没有真正收到错误消息。我基本上收到一条浏览器消息,该页面无法加载。
这是在 Ubuntu 服务器上运行的 PHP 5.5.9。我们确实在 8 月 11 日收到了来自 ubuntu 的一些 php 包的更新。
代码如下:
$connection = ssh2_connect('fe01.xyz.com', 22);
if (!$connection) die('Connection failed');
echo "connected<br>";
$u=ssh2_auth_password($connection, 'username', 'password');
if (!$u) :
echo "auth failed ";
exit;
else:
echo "auth success<br>";
endif;
$outdata=file_get_contents("files/ulti99.csv");
$resSFTP = ssh2_sftp($connection);
if (!$resSFTP):
echo "SFTP Connection Failed";
exit;
else:
echo "SFTP Connection Succuess<br>";
endif;
$resFile = fopen("ssh2.sftp://{$resSFTP}/ulti99.csv", 'w'); // failing
echo "after open";
fwrite($resFile, $outdata );
fclose($resFile);
如有任何帮助,我们将不胜感激。
最佳答案
也许您更改了服务器中的文件权限。
关于PHP ssh2.sftp 停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45760802/