Jump to content


Photo

Displaying Directory Subdirectories


  • Please log in to reply
3 replies to this topic

#1 ibanez270dx

ibanez270dx
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 28 August 2006 - 06:13 PM

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

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 28 August 2006 - 10:24 PM

Here is a function that will do what you want:

http://us2.php.net/m...addir.php#64613

Make sure that the directory has the correct permissions for the web server user to be able to read from it.  For example, I have a script that does the same thing on an IIS6 server...reads the files in a directory that is stored on a network share.  However, the IUSR_servername user doesn't have permissions on the directory, and can not access it.  I have to run that script as my username, because I have permissions on the directory.

#3 paruby

paruby
  • Members
  • PipPipPip
  • Advanced Member
  • 48 posts

Posted 06 December 2006 - 02:39 AM

hitman6003 - Can you tell me how you run the scrpt as your username?

Thanx - paruby

#4 keeB

keeB
  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 06 December 2006 - 04:42 AM

<?php
/**
 * @author: keeb
 * @description: return all sub directories from a directory
 *  
 */
function fileTypeFilter($path) {
	return glob($path . "/*");
}
 
function isDirectory($directory) {
	return is_dir($directory);
}
 
 $path = "/var/www/audio";
 $subfolders = array();
 $folders = fileTypeFilter($path); 
 
 foreach ($folders as $sub) {
 	if (isDirectory($sub)) {
 		array_push ($subfolders, $sub);	
 	}
 }
 
 
?>

$subfolders contains a list of the subfolders in the directory.

Good luck ;)

Come visit my site to see my latest projects
http://nick.stinemates.org/wordpress/





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users