How to count number of files on a remote server that connected with FTP?

This is my code but it doesn't work

```
<?php
    @$ftp = ftp_connect("host");
    @ftp_login($ftp, "usr", "pwd");
    ftp_chdir($ftp,'uploads/');
    echo count(glob(ftp_pwd($ftp) . '*'));
?>

```

Thanks!