tags:

views:

58

answers:

2

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.

+2  A: 

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.

Artefacto
I am able to log in to the same FTP server via FireFTP with the same credentials.
letseatfood
@letseatfood From the production server? Another thing: increase the error_reporting level in PHP and see what the error message is.
Artefacto
@Artefacto - Whoops, my bad, not the production server. Trying now...
letseatfood
@Artefacto - Sorry, but do you mean for me to log in via the shell and use ftp? I am still new to this. Usually I use an ftp client on my machine.
letseatfood
The server itself may be blocking outgoing FTP connections...
gnarf
+2  A: 

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

wimvds