I'm assuming you want the php script to act on the subfolders
The google search would be something like "php recursive script"
I have one that I use to make a folder tree of pdf files downloadable, it may provide an insight, it is probably badly written, but functions ok for my purposes
<?php
function get_Extension($ff){ $path_parts = pathinfo($ff);
if ($path_parts["extension"]) { $m_Extension = strtoupper($path_parts["extension"]);
return($m_Extension);}
else return("unknown");}
function check_file($ff){$temp=get_Extension($ff);
if(($temp=="PDF")) return (true);
else return (false);}
function printQueue($queue, $path) { asort($queue); foreach($queue as $file) { printFile($file, $path); } }
function printFile($file, $path) { if (check_file($file)) { echo '<li><a href="./savefile.php?file='.$path.$file.'">'.substr($file,0,strlen($file)-4).'</a></li>';}}
function printSubDir($dir, $path) { echo "<li>$dir";
createDir($path.$dir."/");
echo "</li>";}
function createDir($path = './') { if ($handle = opendir($path)){ echo "<div style='margin-bottom:1em;'><ul>";
$queue = array();
while (false !== ($file = readdir($handle))) { if (is_dir($path.$file) && $file != '.' && $file !='..') { printSubDir($file, $path, $queue);}
elseif ($file != '.' && $file !='..') {$queue[] = $file;}}
printQueue($queue, $path);
echo "</ul></div>"; }}
createDir(); ?>
savefile.php, referenced in the script is a force-file-download script not required for the recurse function
almostbob
Nearly a Senior Poster
3,305 posts since Jan 2009
Reputation Points: 585
Solved Threads: 403
Skill Endorsements: 7
thinking about what to alter {begin jeopardy thinking music}
almostbob
Nearly a Senior Poster
3,305 posts since Jan 2009
Reputation Points: 585
Solved Threads: 403
Skill Endorsements: 7