Kai McKenzie
Kai McKenzie

Reputation: 515

PHP Warning: ftp_get(): Unable to build data connection: Connection timed out with scheduled task

I am trying to download files to a server after the service provided updated their servers. The login information is accurate. I used a generic code to do this. Example:

<?php  $file = $ROOT.$_GET['file'];
       $ftp_server = "127.0.0.1";
       $ftp_user_name = "user";
       $ftp_user_pass = "pass";
       // set up a connection or die

       $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 

       // login with username and password
       $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

       if (ftp_get($conn_id, $file, $file, FTP_BINARY)) {    
           echo "Successfully written to $file\n";
       } else {    
           echo "There was a problem\n";
       }
       ?>

I was able to contact the service providers but now they are telling me that ftp_get is outdatd or something like that. Is there something i can do on my end to resolve this?

Upvotes: 3

Views: 5910

Answers (1)

Kai McKenzie
Kai McKenzie

Reputation: 515

After further research I found that when I used ftp_pasv the problem did not occur. I assume that some server settings were changed without notification.

ftp_pasv($conn_id, TRUE);

if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { ...

Upvotes: 13

Related Questions