0

I have tried so many things but ftp_connect and ftp_ssl_connect are not working in my development instance.

I am using MAC and PHP8.1, I am trying to connect to localhost with the below simple script:

<?php
    
    // Connect to FTP server
    $ftp_server = "localhost";
    
    // Establish ftp connection
    $ftp_connection = ftp_connect($ftp_server, 22, 10)
        or die("Could not connect to $ftp_server");
    
    if($ftp_connection) {
        echo "Successfully connected to the ftp server!";
        
        // Closing connection
        ftp_close($ftp_connection);
    }
    
    ?>

This is always returning bool(false) instead of the FTP/Connection object. I have also checked the Firewall, it is disabled on my local machine.

Do we need to configure anything in order to work with it?

Thanks

3
  • "localhost" should be the server itself. Is there an FTP server running on that server? Can you anonymously FTP into that server? From your command line try ftp localhost (you may need to use the webserver user since the PHP script is running as that user)... You may need to use ftp_login Jun 23 at 14:45
  • Thanks, @MagePalExtensions for your reply. I tried ftp localhost, it is working and also I am able to connect through FTP client FileZilla. Please help me I am still unable to connect via ftp_connect.
    – Abhinav
    Jun 27 at 5:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.