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.
Link to comment
Share on other sites

  • 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 ;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.