Jump to content

Recommended Posts

Good day to you all,

 

      I'm working on a piece of code which list directory into a dropdown box.

      No problem, with that :

 




<p>List Box - Single Select<br>
<select name="listbox" size="1">
<option  selected>Click here to see them by themes</option>
<?PHP

if ($handle = opendir('themes/')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            $fileName = str_replace('.mov', '', $file);
            echo '<option value="' . $file . '">' . $fileName . '</option>';
        }
    }
    closedir($handle);
}




?>

</select>
</p>

 

 

 

Now what I would like to do is :

 

1- Read the directory recursively .

 

 

Thanks !

 

I did this awhile back. You need to determine if you have a file or a directory when the listbox is created. PHP has built in functions for this and for determining if the file and or directory is readable. What I did is then attached a var called type to the post and indicated file or directory for each link. you can be creative with how you chose to go about this solution. So when they chose a directory then you will have the listbox regenerated with the next level. To achieve this effect you should make a session variable or again attach it to the selection as a tunneled location. I chose to use sessions so that I could hide the actual directory structure from the user. To make the form faster and more efficient I also used AJAX to re write the div each time until a file was selected. Also you will need special processing in order to handle a user selecting ".." in order to back up. This can cause a problem to because you need to detect that they do not back up further than you would like them to be able to; ie don't let them go deeper than the starting point.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.