auto directory listing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mkyb14
Forum Newbie
Posts: 12
Joined: Sat May 28, 2005 7:46 pm

auto directory listing

Post by mkyb14 »

is there a way with php to make it so that if a php page links to a apache directory with no webpages as in php, html. That php will auto generate a basic page with links to each of the files with in that directory? i'm looking to use a function like this for certain directory's for music files and wanted to know if this was possible so that i'm not trying to code each file to be downloadable!!!!!!....... is this possible with php? if not what other language?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Create a file in that folder called .htaccess
Enter this in the file

Code: Select all

Options +Indexes
I think this should do but someone more experienced in htaccess can fix this.
mkyb14
Forum Newbie
Posts: 12
Joined: Sat May 28, 2005 7:46 pm

no code?

Post by mkyb14 »

is there no code then. just the file (.htaccess) ... no php page to call the files...?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Thats correct - Apache will automatically list the files for you.
mkyb14
Forum Newbie
Posts: 12
Joined: Sat May 28, 2005 7:46 pm

does that already

Post by mkyb14 »

does that already, but i was hoping that with some sort of php code that i could have it automatically list it with some html/php etc, instead of apache's default dir listing technique
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

You can, but you'd have to place an index.php in each folder you want php to do the work.
Take a look at http://www.php.net/glob
Post Reply