DIR in FTP

hi everybody!!
how to list of All directories and subdirectories and files existing in ftp

Are you talking about FTP as in FileZilla? If you are, that’s going to be the software, not PHP. PHP cannot affect a software like FileZilla. If you’re talking about just displaying everything on the webpage, you can use the glob function.

Hi,

As trooper said, first of all confirm that how does you want to handle the FTP file, like using File Zilla software.
Here is a link that can help yours.

Hi,
Thanks for the reply.
Do you have a link for php?

Best regards,

Yes, http://php.net/manual/en/function.ftp-rawlist.php

hi,
Thanks for reply.
I just need a list of path for All directories and subdirectories and files existing in ftp php script.
I have already use ftp_nlist but the subdirectories was ignore. Do you have idea for this?

Best regards,

<?php
function getDirContents($dir, &$results = array()){
    $files = scandir($dir);

    foreach($files as $key => $value){
        $path = realpath($dir.DIRECTORY_SEPARATOR.$value);
        if(!is_dir($path)) {
            $results[] = $path;
        } else if($value != "." && $value != "..") {
            getDirContents($path, $results);
            $results[] = $path;
        }
    }

    return $results;
}

var_dump(getDirContents('/xampp/htdocs/WORK'));

Get all the files and folders in a directory, don’t call function when you have . or …

If you are dealing with FTP, why not just use a 3rd party file manager? It would be much easier to manage then making your own because with things like this, security is the huge issue.

I suggest extplorer. With extplorer, you can create, edit, and delete files and directories. It is very smooth and you can add and remove users to access a specific directory or the root directory.

yes, it is but the server is in FTP. This is my script :

if(($ftp = ftp_connect("192…)) == false)
{
echo ‘Erreur de connexion…’;
}

if(!ftp_login($ftp, “login”, “psw”))
{
echo ‘L'identification a échoué…’;
}
/*
$liste_fichiers = ftp_mlsd($ftp, ‘.’);

foreach($liste_fichiers as $fichier)
{
echo $fichier. ‘
’;
}

ok thanks for all reply but i have already find the script. Like this : enter link description here

:wink:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.