views:

31

answers:

1

howdy, can't get it done!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>FTP Download</title>
</head>
<body>
    <?php

    set_time_limit(300);//for setting 
    $path='/userupload';
    $ftp_server='202. …';
    $ftp_server_port="21";
    $ftp_user_name='al…';
    $ftp_user_pass="mypassword";

    // set up a connection to ftp server
    $conn_id = ftp_connect($ftp_server, $ftp_server_port); 
    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

    // check connection and login result
    if ((!$conn_id) || (!$login_result)) { 
        echo "Fail</br>";
    } else {
        echo "Success</br>";
        // enabling passive mode
        ftp_pasv( $conn_id, true );
        // get contents of the current directory
        $contents = ftp_nlist($conn_id, $path);
        // output $contents
        var_dump($contents);
    }

    // close the FTP connection
    ftp_close($conn_id);

    ?>
</body>
</html>

any idea what I'm doing wrong? it always returns "Success bool(false)"! So the connection is working, however the files won't get listed. Any ideas?

regards

A: 

what I'm doing wrong?

you've lack of debugging.

checking only connect result is not enough. have to check every operation as well.

did ftp_pasv() worked?
is there /userupload dir?

Col. Shrapnel
did ftp_pasv() work? -> I have no idea!is there a /userupload dir? -> sure, there is!
@mathiregister you misunderstood. You don't have to answer these questions here. you have to write code that checks every operation result. and find the point where things goes wrong
Col. Shrapnel
how can i check if ftp_pasv() worked?
@mathiregister the same way as previous statements. every function has return value that can be checked
Col. Shrapnel
i have no chance to find the bug! i would be really grateful if you could help me out.