Jump to content

Detecting a Directory?


Demonic

Recommended Posts

Can someone tell me how I can list all subdirectory in a directory?

like:

Main Directory
>Sub1
>Sub2

then check it in a script so the directories come up in a select box

<select name="dir">
<?php
//while statement here
?>
<option value="directoryname">Directoryname</option>
<?php
}//end that whilestatement
?>
</select>
Anybody got ideas on how to do that? Thanks.
Link to comment
https://forums.phpfreaks.com/topic/28028-detecting-a-directory/
Share on other sites

Thats how you do it :D

[code]
<?php
  echo '<h1>Index of /styles/</h1>';
  echo '<ul>';
  echo '<li><a href="/"> Parent Directory</a></li>';
$a = (glob('styles/*', GLOB_ONLYDIR));

foreach($a as $v){
echo "<a href='/".$v."'>".$v."</a><br />";
}
  echo '</ul>';
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/28028-detecting-a-directory/#findComment-128243
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.