服务器不能接受参数.在shell中FTP上传


Server can not accept argument. FTP upload in shell

    $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():服务器不能接受参数。

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

你试过打开被动模式吗?我过去也遇到过同样的问题,这是因为运行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.