PHP FTP + NAT 后的被动 FTP 服务器

2023-10-30php开发问题
1

本文介绍了PHP FTP + NAT 后的被动 FTP 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试在我的网站和远程服务器之间进行 ftp 上传.

I'm trying to do an ftp upload between my website and a remote server.

我收到此错误 PHP 警告:ftp_put(): php_connect_nonb() failed: Operation now in progress (115).

I'm getting this error PHP Warning: ftp_put(): php_connect_nonb() failed: Operation now in progress (115).

我做了研究,我相信这是问题 http://www.elitehosts.com/blog/php-ftp-passive-ftp-server-behind-nat-nightmare/

I did research and I believe this is the problem http://www.elitehosts.com/blog/php-ftp-passive-ftp-server-behind-nat-nightmare/

问题是,我无法下载补丁,因为我使用的是 Godaddy Cpanel,他们说我们拥有的主机不允许它,我也无法通过 ssh 进入它以运行命令行.

The thing is, I cannot download the patch because I'm using Godaddy Cpanel, and they said the hosting we have does not allow it and I also cannot ssh into it to be able to run command line.

我读到在 PHP v5.6+ 中应用了补丁,但我无法获得 ftp_set_option($ftpconn, USEPASVADDRESS, true);去工作.它不识别USEPASVADDRESS,我认为它会,因为我使用的是v5.6.22.

I read that in PHP v5.6+ the patch was applied but I cannot get ftp_set_option($ftpconn, USEPASVADDRESS, true); to work. It doesn't recognize USEPASVADDRESS, which I thought it would because I'm using v5.6.22.

推荐答案

也许你已经设法绕过它,但正确使用的常量是 FTP_USEPASVADDRESS,而不仅仅是 USEPASVADDRESS,不管你能找到什么 在噩梦页面.这与 Godaddy 或其他主机无关(但请注意,我不使用 Godaddy,所以我不能打赌它在那里工作).

Maybe you've already managed to get around it, but the correct constant to use is FTP_USEPASVADDRESS, not just USEPASVADDRESS, regardless of what you can find at the nightmare page. That's independent of Godaddy or other hosting (but please note that I don't use Godaddy, so I can't bet it works there).

此外,噩梦页面上的示例可能会产生误导,因为它报告了使 PHP 表现得好像该选项根本不存在的代码(例如,使其表现得像默认情况下一样):

Moreover, the example at the nightmare page can be misleading, because it reports the code to make PHP behave as if that option didn't exist at all (e.g. make it behave like it already does by default):

ftp_set_option($ftpconn, USEPASVADDRESS, true);
echo "USEPASVADDRESS Value: " . ftp_get_option($ftpconn, USEPASVADDRESS) ? '1' : '0';
ftp_pasv($ftpconn, true);

我认为该页面可以提供的最佳示例应该是这样的:

I think the best example that page could give would be something like this instead:

ftp_set_option($ftpconn, FTP_USEPASVADDRESS, false);
echo "FTP_USEPASVADDRESS Value: " . ftp_get_option($ftpconn, FTP_USEPASVADDRESS) ? '1' : '0';
ftp_pasv($ftpconn, true);

例如它可以展示如何实际使用该选项,而不是如何浪费一行代码将选项设置为其默认值.

e.g. it could show how to actually use that option, not how to waste a line of code to set an option to its default value.

这篇关于PHP FTP + NAT 后的被动 FTP 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17