# Help for folder listing

**URL:** https://forum.kirupa.com/t/help-for-folder-listing/252183
**Category:** Uncategorized
**Created:** [February 17, 2008, 3:41pm UTC](https://forum.kirupa.com/t/help-for-folder-listing/252183 "2008-02-17T15:41:49Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rajha](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@rajha](https://forum.kirupa.com/u/rajha)
#### Post date: [February 17, 2008, 3:41pm UTC](https://forum.kirupa.com/t/help-for-folder-listing/252183/1 "2008-02-17T15:41:49Z")

</div>

i must create a script that read all folders and subfolders on a server

i found this script :

(PHP)  
\<?php  
// Note that !== did not exist until 4.0.0-RC2  
$dir=$\_POST[‘dir’];

if ($handle = opendir($dir)) {  
echo "Directory handle: $handle  
";  
echo "Files:  
";

// Counter  
$i=0;

/\* This is the correct way to loop over the directory. \*/  
while (false !== ($file = readdir($handle))) {  
$return.="&item".$i."=".$file."  
";  
$i++;

}

closedir($handle);

}  
echo $return."&n=".$i;  
?\>

(FLASH)  
var lv = new LoadVars();  
lv.onLoad = function() {  
var count:Number = parseInt(this[‘n’]);  
for (var i = 0; i\<count; i++) {  
var currItem = this[‘item’+i];

```
   //Check to see if its a folder or not
    if (currItem.indexOf(".") == -1) {
        var Branch = myTree.addTreeNode(currItem, "/"+currItem);
        myTree.setIsBranch(Branch, true);

    } else {
        myTree.addTreeNode(currItem, "/"+currItem);
    }
}

```

};  
lv.dir = “prova”;  
lv.sendAndLoad(“dir.php”, lv, “POST”);

but this script read only the first folder.  
ther’s a way to read (with php) all folders and subfolders on server and publish somthing like:

firstfolder/firstsubfolder/etc…  
secondfolder/firstsubfolder/etc…  
etc…

thanks for help

(sorry for my english)
