0
    $local = 'WP_Inv.csv';
    $remote = 'WP_Inv.csv';
    $user = "User861";
    $pass = "topsecret";
    $host = 'ftp.server.com';
    $port = '21';
    $timeout = '90';
    $type = FTP_ASCII;

    $conn_id = ftp_connect($host,$port,$timeout);

    $login = ftp_login($conn_id, $user, $pass);

             ftp_put($conn_id, $remote, $local, $type);

从 shell 运行时返回以下错误:

最后一行显示错误,任何帮助都会很棒,我正在拔头发!

PHP 警告:ftp_put():服务器不能接受参数。

(是的,我稍后在代码中关闭了我的连接)

4

1 回答 1

4

你试过开启被动模式吗?我过去也遇到过同样的问题,这是因为运行 php 代码的机器和 ftp 服务器无法在活动连接上握手。

http://php.net/manual/en/function.ftp-pasv.php

bool ftp_pasv ( resource $ftp_stream , bool $pasv )
ftp_pasv() turns on or off passive mode. In passive mode, data connections are initiated by the client, rather than by the server. It may be needed if the client is behind firewall.

Please note that ftp_pasv() can only be called after a successfull login or otherwise it will fail.
于 2013-05-31T20:43:37.647 回答