fuddy Posted April 29, 2010 Share Posted April 29, 2010 I have a directory structure that is constantly being updated. Config (Root) --City (Sub-Dir) ----Address (Sub-Dir) ------File I'm trying to create a script that will: 1. Scan a directory (will be a root dir) and place the directory names in a drop down box. 2. Choose option (dir) and a 2nd box will appear with subdirectores 3. Once you select an option, a 3rd will be presented 4. This directory will have 1 file that needs to be downloaded <?php $dir = "D9034-Configs"; if (isset($_GET['Site'])) { $Site = $_GET['Site']; } else { $Site = $_POST['Site']; } if (isset($_GET['IP_Address'])) { $IP_Address = $_GET['IP_Address']; } else { $IP_Address = $_POST['IP_Address']; } if (!(isset($Site))) { ?> <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <select name="Site" id="Site"> <?php $output = shell_exec('ls ./'.$dir.'/'); $dirs = explode("\n", $output); foreach ($dirs as $key => $value) { ?> <option value="<?php echo $value?>"><?php echo $value?></option><?php } ?> </select> </form> <?php } if (isset($Site)) { ?> <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <select name="Site" id="Site"> <?php $output = shell_exec('ls ./'.$dir.'/'); $dirs = explode("\n", $output); foreach ($dirs as $key => $value) { if ($value == $Site) { ?> <option value="<?php echo $value?>" SELECTED><?php echo $value?></option><?php } else { ?> <option value="<?php echo $value?>"><?php echo $value?></option><?php } } ?> </select> <select name="IP_Address" id="IP_Address"> <?php $output = shell_exec('ls ./'.$dir.'/'.$Site.'/'); $dirs = explode("\n", $output); foreach ($dirs as $key => $value) { ?> <option value="<?php echo $value?>"><?php echo $value?></option><?php } ?> </select> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/200111-drop-down-boxes-from-directory-tree/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.