Page 1 of 1

Display Directory Subfolders

Posted: Mon Aug 28, 2006 1:08 pm
by ibanez270dx
Hi,
I need to make a script to display the subfolders of a network directory (for example, \\network\users$\ ) ... I don't think I'm using the dir function correctly, and I don't exactly understand how it works from php.net... can someone help me out?

Thanks,
- Jeff

Posted: Mon Aug 28, 2006 1:13 pm
by pickle
Use chdir() & glob() with the GLOB_ONLYDIR parameter.

Posted: Mon Aug 28, 2006 1:25 pm
by ibanez270dx
How do I use them? Here is my code currently... it won't even show anything - just a blank page...

Code: Select all

foreach (glob_onlydir("\\network\users$") as $dirname) 
	{
   	 $display_names .= "$dirname";
	}
I haven't used the foreach or glob functions before, and PHP.net doesn't exactly make sense to me... sorry I'm not a pro at this...

Posted: Mon Aug 28, 2006 1:35 pm
by Oren
There isn't such function "glob_onlydir" :P

pickle meant to this:

Code: Select all

glob('*', GLOB_ONLYDIR)

Posted: Mon Aug 28, 2006 1:43 pm
by ibanez270dx
cool - now I don't have just a blank page... using the following code, I only get the output "array". I haven't worked with arrays either... :oops:

Code: Select all

$directories = glob('\\network\users$\*', GLOB_ONLYDIR)
I need it to basically read all the names of the directories within \\network\users$\ and display them... Please help me!

Posted: Mon Aug 28, 2006 2:04 pm
by Oren
This topic has been discussed before, use the search :wink:

Posted: Mon Aug 28, 2006 2:15 pm
by pickle

Posted: Mon Aug 28, 2006 2:24 pm
by ibanez270dx
Hi,
Ok, so I got it to display the folder names... but I couldn't get it to display it from the network... (I did the testing in the current directory). However, I need it to go to \\network\users$\ . That is the path it displays from windows explorer, but it won't work in the PHP. Is there anything I'm missing? Here is my code again:

Code: Select all

<?php

$Array = glob('\\network\users$\*', GLOB_ONLYDIR); 
	
foreach($Array as $dirname)
	{
   	 $display_names .= "<a href=viewlog.php?name=$dirname>$dirname</a><br>";
	}

?>