By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,730 Members | 1,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,730 IT Pros & Developers. It's quick & easy.

Drop-Down Directory...Subdirectory..Files

P: 1
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  
  4. $dir = "D9034-Configs";
  5. if (isset($_GET['Site'])) { $Site = $_GET['Site']; } else { $Site = $_POST['Site']; }
  6. if (isset($_GET['IP_Address'])) { $IP_Address = $_GET['IP_Address']; } else { $IP_Address = $_POST['IP_Address']; }
  7.  
  8. if (!(isset($Site)))
  9. {
  10. ?>
  11. <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
  12.   <select name="Site" id="Site">
  13. <?php
  14.   $output = shell_exec('ls ./'.$dir.'/');
  15.   $dirs = explode("\n", $output);
  16.   foreach ($dirs as $key => $value)
  17.   {
  18. ?>    <option value="<?php echo $value?>"><?php echo $value?></option><?php
  19.   }
  20. ?>
  21.   </select>
  22. </form>
  23. <?php
  24. }
  25.  
  26. if (isset($Site))
  27. {
  28. ?>
  29. <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
  30.   <select name="Site" id="Site">
  31. <?php
  32.   $output = shell_exec('ls ./'.$dir.'/');
  33.   $dirs = explode("\n", $output);
  34.   foreach ($dirs as $key => $value)
  35.   {
  36.     if ($value == $Site)
  37.     {
  38. ?>    <option value="<?php echo $value?>" SELECTED><?php echo $value?></option><?php
  39.     }
  40.     else
  41.     {
  42. ?>    <option value="<?php echo $value?>"><?php echo $value?></option><?php
  43.     }
  44.   }
  45. ?>
  46.   </select>
  47.   <select name="IP_Address" id="IP_Address">
  48. <?php
  49.   $output = shell_exec('ls ./'.$dir.'/'.$Site.'/');
  50.   $dirs = explode("\n", $output);
  51.   foreach ($dirs as $key => $value)
  52.   {
  53. ?>    <option value="<?php echo $value?>"><?php echo $value?></option><?php
  54.   }
  55. ?>
  56.   </select>
  57. </form>
  58. <?php
  59. }
  60.  
  61. ?>
Apr 29 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.