FTP uses two sockets:
- One for the commands and responses. This one is opened by the client.
- One for the file transfer (data connection), this one is opened by the remote server in
active mode, and this is the default.
In your case the server running your php script is the client and the other one is the remote server. Thus this later will try to open a connection back to your server. It is most likely, that there is a firewall in between, that is not aware of ftp. No problem, you have to set your ftp client to
passive mode. Use the
ftp_pasv[^] function to set the php ftp client to passive mode.