简体   繁体   中英

Why is ftp_login() authentication failing?

I am attempting to use ftp_login() but continue to get the error:

Warning: ftp_login(): Login authentication failed in /path/to/file.php

I am 100% positive that the username and password are correct. Login succeeds when using an FTP client like WinSCP or FileZilla. There are no symbols in either the password or username.

Here's the code:

$ftp_host = 'host.com'; 
$ftp_user_name =  'user@host.com'; 
$ftp_user_pass = 'password';

$connect = ftp_connect( $ftp_host ) or die( "Couldn't connect to server!!!" );
$login_result = ftp_login( $connect, $ftp_user_name, $ftp_user_pass );

I am using HostGator and I am trying to transfer files this domain to a sub-domain also with HostGator.

Please help. Thanks!

Try dropping @host.com from your $ftp_user_name string.

Use this to see if your credentials are correct:

if (ftp_login($connect, $ftp_user_name, $ftp_user_pass)) {
    echo "Connected as $ftp_user_name@$ftp_host\n";
} else {
    echo "Couldn't connect as $ftp_user_name\n";
}

Note, this code will show errors.

Try changing your ftp password, click View FTP Details and change your password. You're better off with a proper ftp client than a web based file manager though and also they're notorious for corrupting files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM