Test FTP connection with PHP

后端 未结 6 1011
独厮守ぢ
独厮守ぢ 2021-02-05 08:55

I am using the PHP script below to test FTP connections. Currently it is printing an array of the files, if it successfully connects.

How can I get it to also display

6条回答
  •  难免孤独
    2021-02-05 09:29

    Hello I have tried this..Working properly.

    set_time_limit(300);//for setting 
    $path='/'.date('dmY').'';
    $ftp_server='';
    $ftp_server_port="";
    $ftp_user_name='';
    $ftp_user_pass="";
    
    // 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
    "; } else { echo "Success
    "; // 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);

提交回复
热议问题