How to check using PHP FTP functionality if folder exists on server or not?

stumbled upon this question from 2009 and found that question unsatisfying for me. I've done little research of my own a found a little tweak for that issue.

So if found the *ftp_nlist* function witch returns an array of string with files and folders names witch exist under the current ftp directory, and then I've simply checked under the array (with foreacah loop) if the folder or file we searched for exist there and an new ifExist method as been created.

you can

another option for the YII framework users its the ftp extension that masks the php ftp lib and makes it even easier to work with an ftp server from code.

Hope you'l find helpful.

For PHP 5:

$folder_exists = is_dir('ftp://user:[email protected]/some/dir/path'); : "As of PHP 5.0.0, this function can also be used with some URL wrappers." : [Support] "As of PHP 5.0.0: filesize(), filetype(), file_exists(), is_file(), and is_dir()"

Try this:

if (ftp_nlist($ftp_stream, $new_folder) == false) {
    ftp_mkdir($ftp_stream, $new_folder);

There is no 'exists' function for ftp connections in php.

You could try ftp_chdir and check the result