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

PHP FTP + Passive FTP Server Behind NAT(PHP FTP + NAT 后的被动 FTP 服务器)
本文介绍了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 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)