Andrew (deltoideus) wrote in php,


Hi everyone.

Could anyone suggest some explanation to the following:

---- The code ----
$conn_id = ftp_connect('ftp_server_here');
$login_result = ftp_login($conn_id, 'username', 'password');
ftp_pasv($conn_id, true);
$handle = fopen('local_file', "w");
ftp_size($conn_id, 'remote_file');
ftp_fget($conn_id, $handle, 'remote_file', FTP_BINARY);
---- Code end ----

I also created the test output of this script:

---- Output ----
Connection ID returned by ftp_connect [line 2151]: Resource id #29
Login result returned by ftp_login [line 2156]: 1
Switching on ftp passive mode...
Checking if it is possible to open file: "............" for writing   ... Success!
File: ............" handler: Resource id #30
Remote file size: 566.0 KB
PHP Warning: ftp_fget(): php_connect_nonb() failed: Connection timed out (110) in ...... on line 2205
---- Output end ----

Then I tried to connect this FTP using shell:

---- Output ----
$ ftp
Connected to
220 FTP server Ceske WWW.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name ( name
331 Please specify the password.
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd Estonia
250 Directory successfully changed.
ftp> pwd
257 "/Estonia"
ftp> get
(remote-file) estonia.xml
(local-file) estonia_downloaded.xml
local: estonia_downloaded.xml remote: estonia.xml
227 Entering Passive Mode (81,0,233,91,65,138)
ftp: connect: Connection timed out
---- Output end ----

Why could that happen? Any ideas? Something is wrong with FTP or what...
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.