$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);
Run Code Online (Sandbox Code Playgroud)
从 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.
Run Code Online (Sandbox Code Playgroud)