tags:

views:

34

answers:

1

I want to point to a folder and then the php script should take the list of sub directories from that folder and save it into the database

Can anyone provide a php script which would do the same thanks in advance

$path = "new/cat1/";

want to get the list of sub-directories inside the $path folder and save those sub-directory names to database. No need to take the filename of filelist

+1  A: 

PHP 5's new RecursiveDirectoryIterator is the way to go. It's a bit complicated to get into at first but makes things very easy. The User Contributed Notes provide some good examples.

You would have to walk through your directory structure and use is_dir() on each entry (use ->key() to get the full path) to find out whether it's a directory.

Pekka