Righto, here is my current code to print out the files (under $filedir):
Display All
The lines:
SHOULD remove the directories from the listing, but they don't. Without them, no files are displayed. What's going on?
Hopefully some of you are in to PHP.
PHP Source Code
- $dispdir = false;
- function directoryToArray($directory, $recursive) {
- $me = basename($_SERVER['PHP_SELF']);
- $array_items = array();
- if ($handle = opendir($directory)) {
- while(false !== ($file = readdir($handle))) {
- if ($file != '.' && $file != '..' && $file != $me && substr($file,0,1) != '.') {
- if (is_dir($directory.'/'.$file)) {
- if($recursive) {
- $array_items = array_merge($array_items, directoryToArray($directory.'/'. $file, $recursive));
- }
- if($dispdir == true) {
- $file = $directory.'/'.$file;
- $array_items[] = preg_replace('/\/\//si', '/', $file);
- }
- } else {
- $file = $directory .'/'. $file;
- $array_items[] = preg_replace('/\/\//si', '/', $file);
- }
- }
- }
- closedir($handle);
- asort($array_items);
- }
- return $array_items;
- }
- $filelist = directoryToArray($filedir, $recursivelist);
- foreach($filelist as $file) {
- $ext = substr(strrchr($file, '.'), 1);
- if(in_array($ext,$valid_ext) && is_writable($file)) {
- echo '<option value="'.$file.'">$file</option>';
- }
- }
Hopefully some of you are in to PHP.