Jump to content

Archived

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

ibanez270dx

Displaying Directory Subdirectories

Recommended Posts

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

Share this post


Link to post
Share on other sites
Here is a function that will do what you want:

http://us2.php.net/manual/en/function.readdir.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.

Share this post


Link to post
Share on other sites
hitman6003 - Can you tell me how you run the scrpt as your username?

Thanx - paruby

Share this post


Link to post
Share on other sites
[code]
<?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);
}
}


?>
[/code]

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

Good luck ;)

Share this post


Link to post
Share on other sites

×

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.