Jump to content

DIR list Help ?


sfxteam

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.