Re: Help with Dir List

From: Date: Sun, 10 Aug 2008 23:25:46 +0000
Subject: Re: Help with Dir List
References: 1  Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-2362@lists.php.net to get a copy of this message
melvin nieves wrote:
hello my Name is Melvin im developing a Flex APP with PHP. i need some help adding &filesize and file ext. filter 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.'">'; $file_size = filesize($currentPath.$file);
$str .= '<detail type='filesize'name="'.$file_size.'">'; $file_exts = split(".",basename($file)); $file_ext = $file_ext[count($file_ext)-1]; $str .= '<detail type='filetype' name="'.$file_ext.'">'; $str .='</node>';
            }
        }
        closedir($handle);
    }
    return $str;
} readfromhere(); $str.="</root>"; header('Content-Type: text/xml'); echo $str; ?>
here I think this is what your looking for.

« previous php.webmaster (#2362) next »