NAT背后的PHP FTP +被动FTP服务器 [英] PHP FTP + Passive FTP Server Behind NAT

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

问题描述

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

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

我收到此错误PHP警告:ftp_put():php_connect_nonb()失败:操作正在进行中(115).

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

我做了研究,我相信这是问题所在

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在梦m页面上找到 .这独立于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).

此外,梦m页面上的示例可能会引起误解,因为它报告使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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆