0

I try to connect with PHP to an 1and1 Server:

$ftp_connection = ftp_ssl_connect($ftp_server, 22);

if(ftp_login($ftp_connection, $ftp_user, $ftp_pass))
    echo 'true';
else
    echo 'false';

But it always return false and

ftp_login() expects parameter 1 to be resource, boolean given...

He can't get connection. If I try it with FileZilla, the Login works fine, so the login data are correct. Other Servers (not 1and1 works also fine).

What iam doing wrong?

Lars
  • 9
  • 2

1 Answers1

0

Either, you mean to use port 21 (default for FTP) in that case, change 22 to 21 OR since you used port 22 in your provided code, you want to connect via sftp instead. However, PHP's native support for this isn't very good.

Read some of the anwers on the following question: How to SFTP with PHP?

Community
  • 1
  • 1
Daniel
  • 1,229
  • 14
  • 24
  • I tried this before. If I use Port 21 i get this error: ftp_login(): 'AUTH': command unrecognized – Lars Aug 17 '16 at 21:43
  • I'm pretty sure you mean to connect via SFTP (port 22). Try using one of the libraries and see if it allows you to connect. May I also ask for which purpose you want to do this for? – Daniel Aug 17 '16 at 21:45
  • I want to use it for an FTP Browser. This should work for every secure ftp Connection / Server. Okay I will try it with sftp. But i have to change the whole code then :( – Lars Aug 17 '16 at 21:51