在PHP中使用ftp的远程服务器

问题描述:

嗨大家......

我想将远程服务器连接到ftp_put命令。不同的服务器来纠正我的远程服务器示例不正确。我收到此错误无法打开到端口10119的数据连接。如何解决这个问题?

谢谢。

Hi Guys...
I want to connect remote server to ftp_put command. Different servers to correct example my remote server to incorrect. I get this error "Could not open data connection to port 10119". How to solve this problem ?
Thank you.

FTP使用两个套接字:

- 一个用于命令和响应。这个是由客户打开的。

- 一个用于文件传输(数据连接),这个由远程服务器在活动模式下打开,这是默认。

在你的情况下,运行php脚本的服务器是客户端,另一个是远程服务器。因此,稍后将尝试打开连接回您的服务器。最有可能的是,中间有防火墙,不知道ftp。没问题,您必须将您的ftp客户端设置为被动模式。使用 ftp_pasv [ ^ ] 将php ftp客户端设置为被动模式的功能。
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.


非常感谢你使用了

Very thank you I used
ftp_pasv(


baglan,true);
baglan, true);



这解决了这个问题


this solved this problem