Jump to content

show only folders and not files in options


Nic727

Recommended Posts

Hi,

 

For the moment I have this as directory :

 

- Animal

- People

--- Number1.html

--- Number2.html

- test.php

 

That's just an example, but I would like to get a form showing options to select a folder in the current location.

 

Here is my code for now :

<select name='choice'>
	<option value="" disabled selected hidden>Folders</option>
		<?php 
			$folder = getcwd(); 
			echo $folder;
			$element = scandir($folder);			
			foreach($element as $file){
				if($file != '.' && $file!= '..'){
			echo "<option>".$file."</option><br/>";}}
		?>
</select>

For now it show all files/folders in my current location in directory. So it show my test.php in the list.

 

I would like to only get folders and when I select a folder and click the submit button, it should show another select options with the files inside the chosen folder.

After when you click the submit button again with the selected file, it should open this file in the browser.

 

Thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...