PHP ssh2.sftp 停止工作

标签 php ubuntu

下面是运行了一段时间的代码,本周它停止工作了。我已将其缩小到“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/

相关文章:

Docker Ubuntu 选择了错误的目录

python - 分布式微服务监控工具

php - 如果可以将 php 嵌入到 .html 文件中,为什么要使用 .php?

php - 如何使用javascript刷新表格单元格

php - Silex SecurityServiceProvider 抛出 'Identifier "security.authentication_providers“未定义。”

php - 如何在codeigniter中定义全局变量?

python - 以新用户身份在 Ubuntu 中运行脚本时的 Shell 问题

python - 在 Amazon ec2 ubuntu 实例上使用 enthought Python 安装 lxml

docker - 节点容器无法连接到 Ubuntu 21.04 上的 MariaDB 容器

php - 可以在 fpdf 中嵌入 fontawesome 字体吗?