开发者

Why would ftp_connect() return false on production server if it works elsewhere for connecting to the same FTP server?

开发者 https://www.devze.com 2023-01-02 07:26 出处:网络
I have a script that uses ftp_connect() among other FTP PHP functions for uploading a file. ftp_connect() works when executed on my local development server for connecting to a remote FTP server. The

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

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?

Thanks!

Here is the code:

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

No errors are reported.


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).

edit

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).


Probably firewall issues. On top of that, FTP was not designed with NAT in mind.

Try to login to the production server and use a ftp client to do the same connection.


I do not know the things inside it very well but I want to give my little help.My server is ubuntu Linux with Apache、PHP and MySQL,and my develop env is MAMP on Mac.

  1. I met the problem suddenly and cannot find what happened because it was worked yesterday,I searched many answers and can't solved it.The ftp_connect($ftp_server) only return bool(false),but I can use my FileZilla,interesting,is it?

  2. So I try to connect the server from my command line,like ftp 111.22.333.44,It shows:

    500 OOPS: cannot read user list file:/etc/vsftpd/vsftpd.user_list

  3. I login in my ubuntu server, and didn't find the vsftpd directory,and the vsftpd.user_listis in the directory /etc/,still don't know what happened.

  4. So I simply create the directory and copy the file vsftpd.user_list to it.Then I try ftp 111.22.333.44(your IP address) again and it works now.

hope it help someone else.

0

精彩评论

暂无评论...
验证码 换一张
取 消