So you know what that default page looks like in apache when you don't have an "index.html" page and all you see is one that says "index of..."? I remember seeing a php script somewhere that makes it so you can actually control the look and feel of this page instead of leaving the default directory page. Anyone know of some or have created any of your own?
With htaccess you can turn off indexes: Or specify a page other than index.html to use as the index: Is that what you're saying, or you want to have a "fancier" looking page that lists all the files in a directory?
I think he means listing all the files in a directory. function dirList ($directory) { // create an array to hold directory list $results = array(); // create a handler for the directory $handler = opendir($directory); // keep going until all files in directory have been read while ($file = readdir($handler)) { // if $file isn't this directory or its parent, // add it to the results array if ($file != '.' && $file != '..') $results[] = $file; } // tidy up: close the handler closedir($handler); // done! return $results; } Code (markup): There's a function to do that! Hope it helps! If you need more help PM me, green rep?
I've never really thought to ask for rep. Just adding on to what has been posted so far if you have some directories with index.html pages and some without you may need to get slightly complex so set the directory index to your custom file and then in that file check whether a index.html page exists and if it does redirect. If it doesn't then proceed with what chuckd1356 started.
Exactly... I remember coming across a script that did this somewhere. I want to be able to put files into the directory and have it display the files dynamically. Basically, I want the default type of directory listing page without the generic look. Maybe something where I can control the design.
Ok, so take that function chuck posted, have a script that lists all the files in the current directory ... $list = dirlist(".") will put an array of every file in the current folder into the $list variable, then you can loop through it like you want. Set the DirectoryIndex in htaccess to point to that script that lists the files and you can make it look any way you like.
OK, would love to but I need some tips on how to integrate the function into index.php. I am not very skilled at php yet as I am only slightly familiar with the basics (variables, includes, etc). Any tips?
chuckd1356 has set up the most important part of the script. You might also want to access the last access/modified time and size using stat.
I found something similar to what I have been looking for. it's not 100% what I wanted but it's a start. Thought I would post this in case others were interested: http://www.sweetphp.com/nuke/modules.php?name=Script_Preview&script=3