如果ftp_connect()在生产服务器上可以在其他位置连接到同一FTP服务器,为什么它会在生产服务器上返回false? [英] Why would ftp_connect() return false on production server if it works elsewhere for connecting to the same FTP server?

查看:54
本文介绍了如果ftp_connect()在生产服务器上可以在其他位置连接到同一FTP服务器,为什么它会在生产服务器上返回false?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,其中使用 ftp_connect()和其他FTP PHP函数来上传文件.

I have a script that uses ftp_connect() among other FTP PHP functions for uploading a file.

ftp_connect()在我的本地开发服务器上执行以连接到远程FTP服务器时可以工作.在远程服务器上执行时,相同的脚本不适用于连接到完全相同的FTP服务器.

ftp_connect() works when executed on my local development server for connecting to a remote FTP server. The same script, when executed on the remote server does not work for connecting to the exact same FTP server.

有人可以指出正确的方向吗?

Could somebody please point me in the right direction?

谢谢!

这是代码:

error_reporting(E_ERROR | E_WARNING | E_PARSE);
$server = 'ftp.someserver.com';
$ftpConn = ftp_connect($server);
if(!$ftpConn)
    echo 'failed';
else
    echo 'success';

没有错误报告.

推荐答案

因此,如果我正确理解它,则上面的脚本已安装在您尝试使用FTP访问的服务器上(即,该脚本正在打开本地FTP连接)?什么用途?PHP中的FTP仅用于在2个服务器之间传输文件,您不能使用它将文件从客户端传输到服务器(因为脚本是在服务器上执行的).

So if I understand it correctly then the script above is installed on the server that you're trying to access using FTP (ie. the script is opening a local FTP connection)? What's the use? FTP in PHP is only useful to transfer files between 2 servers, you cannot use it to transfer files from the client to the server (since the script is executed on the server).

修改

我没有在原始注释中添加一些内容:如果要将文件从客户端传输到服务器,则可以使用Java FTP小程序.但是请注意所涉及的安全问题(因为可以窃听用户凭据:p).

Something I didn't add in my original comment : you could use a Java FTP applet if you want to transfer files from the client to the server. But be aware of the security issues involved (because the user credentials can be sniffed :p).

这篇关于如果ftp_connect()在生产服务器上可以在其他位置连接到同一FTP服务器,为什么它会在生产服务器上返回false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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