Jump to content

Displaying Directory Subdirectories


ibanez270dx

Recommended Posts

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.
  • 3 months later...
[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 ;)

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.