sfxteam Posted August 5, 2008 Share Posted August 5, 2008 hello im new here. I just need help with dir list with php. i need to add filesize and extension filter to this code. thanks in advanced. <?php $str = "<root>"; function readfromhere($path=".") { global $str; $currentPath=($path == '.' ? './Shared/' : $path.'/'); //echo "<pre>"; //var_dump($currentPath); //echo "</pre>"; if ($handle = opendir($currentPath)) { while (false !== ($file = readdir($handle))) { //echo "<pre>"; //var_dump($file); //echo "\n"; //var_dump(is_dir($currentPath.$file)); //echo "</pre>"; if (is_dir($currentPath.$file) && $file != "." && $file != "..") { $str.='<node type="folder" name="'.$file.'">'; readfromhere($currentPath.$file); $str.='</node>'; } else if ($file != "." && $file != "..") { $str.='<node type="file" name="'.$file.'" path="'.preg_replace('/\.\/+/i','',$currentPath).$file.'"> </node>'; } } closedir($handle); } return $str; } readfromhere(); $str.="</root>"; header('Content-Type: text/xml'); echo $str; ?> Link to comment https://forums.phpfreaks.com/topic/118340-dir-list-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.