In order to read sub folders you will need to use a function. See the code below for a basis of just outputting the files.
Change the path at the very bottom of the code snippet to the path you want to look at. PHP must have access to that path for the script to execute. Try it out.
function read_my_dir($dir){ global $tfile,$tdir;$i=0;$j=0;$myfiles; $myfiles[][] = array(); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file=readdir($dh)) !== false) { if (!is_dir($dir."\\".$file)) { $tfile[$i]=$file; $i++; echo $dir."\\".$file." - <b>File</b><br>"; } else { if (($file != ".") && ($file != "..")) { $tdir[$j]=$file; echo $dir."\\".$file." - <b>Directory</b><br>"; //$sep = "\\"; read_my_dir($dir."\\".$file); $j++; } } } closedir($dh); } }}read_my_dir("C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\experts-exchange");
Change the path at the very bottom of the code snippet to the path you want to look at. PHP must have access to that path for the script to execute. Try it out.
Open in new window