This function is way faster than those below for checking if an object is a file or folder.
<?php
function is_ftp_dir($file, $ftp_connection){
    if(ftp_size($ftp_connection, $file) == '-1'){
        return true; // Is directory
    }else{
        return false; // Is file
    }
}
?>