[UPHPU] simple??? php function (display an index)

Caleb Call caleb at macjunk.org
Wed Jul 19 16:32:20 MDT 2006


this worked exactly as I wanted, thanks!!!  I had found a few other  
ways to do it such as readdir but I couldn't get them to display as  
links (I see how now, include the <a href... stuff (duh)!

One last question, to add on to this a little, where you have "Select  
the file you want to go to:" is there a way to display the current  
directory you are in so it could read "Index of <Current directory>"  
or say what ever but display the current directory?

Thanks again.


On Jul 18, 2006, at 11:14 PM, Saint Chaos wrote:

> On 7/18/06, Caleb Call <caleb at macjunk.org> wrote:
>>
>> Is it possible (or is there a simple way to) create an index.php page
>> that will just show all the files in the directory?  Similar to not
>> having any index page at all.  I'd like to just show the files but
>> I'd also like to be able to apply a stylesheet to the directory?
>> I've tried searching php.net but I really don't know what I am
>> searching for.  Any help would be greatly appreciated.
>
>
>
> Something like this (from Zend Studio code snippets):
> ______________________________________________________________________
> <?
> /********************************************************************
> *    function that reads directory content and
> *    returns the result as links to every file in the directory
> *
> *    toss it into any directory and get a list of links to every file
> *
> *       This program is free software licensed under the
> *       GNU General Public License (GPL).
> *
> *********************************************************************/
> function directory($result) {
>
>     $handle=opendir(".");
>     while ($file = readdir($handle)) {
>     if ($file == "." || $file == "..") { } else { print "<a
> href=$file>$file</a><br>\n"; }
>
>     }
>     closedir($handle);
>
> return $result;
> }
>
>
> ?>
> <b>Select the file you want to go to:</b>
> <p>
> <?
> echo directory($result);
> ?>
> ______________________________________________________________________
>
>
>
> -- 
>> From the ashes shall rise a new age. An age without rules, without  
>> laws and
> without men.
>
> _______________________________________________
>
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net



More information about the UPHPU mailing list