Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 753
Kai McKenzie Avatar asked Dec 07 '25 03:12

Kai McKenzie


1 Answers

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)) { ...
like image 163
Kai McKenzie Avatar answered Dec 08 '25 20:12

Kai McKenzie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!