Just check the size of a file. If the size is -1
, it doesn't exist, so:
$file_size = ftp_size($ftp_connection, "example.txt");
if ($file_size != -1) {
echo "File exists";
} else {
echo "File does not exist";
}
If the size is 0
, the file does exist, it's just 0 bytes.
Source