gpt4 book ai didi

php - 使用 sftp 和 ssh2 的 fopen 段错误

转载 作者:可可西里 更新时间:2023-11-01 13:05:41 26 4
gpt4 key购买 nike

我有一个在 AWS 上运行的 php 系统和一个使用 shh2sftp 在外部服务器上上传 xlsx 文件的类。此代码在上次升级 aws 包 openssh-clients-6.6.1p1-31.62openssh-server-6.6.1p1-31.62 之前一直运行良好,此时我有一个 <fopen 期间出现 strong>segfault。Fopen 在外部服务器上创建一个文件。这里的代码:

$stream = @fopen("ssh2.sftp://$this->sftp$remote_file", 'w');

然后我使用 $stream 来编写内容,但是代码停止在 fopen 上,因为出现了段错误。我没有找到关于这个问题的任何信息,我认为问题是 opnessh 的新升级,因为 php 代码没有改变。有什么想法吗?

最佳答案

在 StackOverflow 上找到答案: https://stackoverflow.com/a/40972584/2520795

似乎自从这次 PHP 更新后,您必须用 intval() 包围您的主机部分(ssh2_sftp() 的结果):

$handle = opendir("ssh2.sftp://".intval($sftp)."/path/to/directory");

在我的例子中,有一个 fopen 而不是 opendir,但解决方案是一样的。

关于php - 使用 sftp 和 ssh2 的 fopen 段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41118475/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com