Warning: ftp_login(): User cannot log in, home directory ina


Warning: ftp_login(): User cannot log in, home directory inaccessible

我正在尝试连接并从服务器检索文件,但我得到以下错误:

Warning: ftp_login(): User cannot log in, home directory unavailable。

define('FTP_HOST', 'example.com');
define('FTP_USER', 'xxxx');
define('FTP_PASS', 'xxxx');
$conn_id = ftp_connect(FTP_HOST) or die("Couldn't connect"); 
echo var_dump($conn_id);
$c = ftp_login($conn_id, FTP_USER, FTP_PASS);
echo "<br>";
echo var_dump($c);

有时使用被动模式还是主动模式进行连接也很重要。我最近遇到了一个和你类似的问题。

你可以在登录前试一下:

// turn passive mode on
ftp_pasv($conn_id, true);

在大多数情况下,只有当没有设置默认FTP站点的FTP授权规则时,才会出现此错误。