Hello Community,
I need help using the ftp_nlist command, what i'm trying to do is look in a directory but the directory is two separate string (eg. "New folder") and it is saying there is nothing in there but there is i'm sure the problem is because the two separate stringed folder name. So is there a way to fix this.

Please help...

Can you show some code?

<?php
    $ftp_server = "SERVER";
    $ftp_user_name = "USERNAME";
    $ftp_user_pass = "PASSWORD";
    $conn_id = ftp_connect($ftp_server);
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    ftp_pasv($conn_id, true);

    if (($conn_id) || ($login_result)) {
        $itemsArray = array();
        $items_list = ftp_nlist($conn_id, "MainDir/SubDir/New folder");
        foreach ($items_list as $item) {
            array_push($itemsArray, array("itemname" => $item));
        }
        unset($itemsArray['0']);
        unset($itemsArray['1']);
?>
<ul>
    <?php
        if (is_array($itemsArray)) {
            foreach ($itemsArray as $item) {
    ?>
    <li><?php echo $item['itemname'] ?></li>
    <?php
            }
        }
        else
            echo $itemsArray;
    ?>
</ul>
<?php
    } else {
        return "An error has occurred!";
    }

    ftp_close($conn_id);
?>

It's probably the space in "New Folder". They warn for this in the manual. See the comment by "aRc" from 9 years ago.

Yer i know it's the space but i want to know if there is a way to bypass that for it to work.

Anyway i tried adding that (ftp_chdir) but i'm getting this error:
Warning: ftp_chdir(): Can't change directory to MainDir/SubDir/New folder: No such file or directory in C:\wamp\www\CheckDir.php on line 11

This is the updated script using that method:

<?php
    $ftp_server = "SERVER";
    $ftp_user_name = "USERNAME";
    $ftp_user_pass = "PASSWORD";
    $conn_id = ftp_connect($ftp_server);
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    ftp_pasv($conn_id, true);

    if (($conn_id) || ($login_result)) {
        $itemsArray = array();
        ftp_chdir($conn_id, "MainDir/SubDir/New folder");
        $items_list = ftp_nlist($conn_id, "");
        foreach ($items_list as $item) {
            array_push($itemsArray, array("itemname" => $item));
        }
        unset($itemsArray['0']);
        unset($itemsArray['1']);
?>
<ul>
    <?php
        if (is_array($itemsArray)) {
            foreach ($itemsArray as $item) {
    ?>
    <li><?php echo $item['itemname'] ?></li>
    <?php
            }
        }
        else
            echo $itemsArray;
    ?>
</ul>
<?php
    } else {
        return "An error has occurred!";
    }

    ftp_close($conn_id);
?>

No such file or directory

Either a typo, or you are not in the folder you think you are.

Never mind i fixed it i didn't enter the correct name of the folder.
Thanks for your help.