Thanks to h3 at valleyfield dot net
Same function with some minor changes and comments added
FTP function checks if a directory exists
<?php
function ftp_is_dir( $dir ) {
    global $ftpcon;
    // get current directory
    $original_directory = ftp_pwd( $ftpcon );
    // test if you can change directory to $dir
    // suppress errors in case $dir is not a file or not a directory
    if ( @ftp_chdir( $ftpcon, $dir ) ) {
        // If it is a directory, then change the directory back to the original directory
        ftp_chdir( $ftpcon, $original_directory );
        return true;
    } 
    else {
        return false;
    }        
} 
?>