The bad thing about trying ftp_chdiris not the need to suppress errors. This is normal if you have a legitimate reason to expect an error. It rather affects directory changes.
If I take this direction, I will try instead ftp_size, since it has no side effects. It must be unsuccessful for directories and succeed for files.
If you connect to one specific server to find out its directory listing format, use ftp_rawlistand analyze its output to determine if the entry is a file or folder.
A typical list on the * nix server is similar:
drwxr-x--- 3 vincent vincent 4096 Jul 12 12:16 public_ftp
drwxr-x--- 15 vincent vincent 4096 Nov 3 21:31 public_html
-rwxrwxrwx 1 vincent vincent 11 Jul 12 12:16 file.txt
This is a host dwho tells you if the entry is a directory or not.
, (.. , ).
- MLSD FTP, . PHP .
MLSD ftp_rawlist:
https://secure.php.net/manual/en/function.ftp-rawlist.php#101071