Creating HTML page of folder contents?

For system help, all hardware / software topics NOTE: use Coders Corner for all coders topics.

Moderators: Krom, Grendel

Post Reply
User avatar
Top Wop
DBB Master
DBB Master
Posts: 5104
Joined: Wed Mar 01, 2000 3:01 am
Location: Far from you.
Contact:

Creating HTML page of folder contents?

Post by Top Wop »

I know there is a similar way when one creates a gallery, but is there a way to automatically generate and display contents of a web folder into an HTML page? Or would a directory listing be better and how would I do that? What I am trying to do is upload some various files to our clients to be accessed by login and since there will be so much volume of files, I want to see if I can upload them and organize them in the fastest and best way possible. Thanks for your suggestions!
User avatar
Tetrad
DBB Alumni
DBB Alumni
Posts: 7585
Joined: Thu Nov 05, 1998 12:01 pm
Location: Dallas, TX

Post by Tetrad »

You can use the default apache directory listing, or if you have PHP you can whip up something really fast. I'd offer to do it myself but I don't know enough PHP to do it off the top of my head. :p
User avatar
Tyranny
DBB Defender
DBB Defender
Posts: 3399
Joined: Sun Nov 10, 2002 3:01 am
Location: Phoenix, Arizona

Post by Tyranny »

Theres only one problem with doing the default directory listing which is if your host has directory lists disabled (as mine does) for safety reasons there really isn't much you can do about that method.

Tobycat is picky about that kind of stuff so I don't really pester him about it. Most, though, allow it with no problems.

Perhaps if you're nice enough to Testi he might whip something up for you pretty quickly if it doesn't require a bunch of time.
User avatar
DCrazy
DBB Alumni
DBB Alumni
Posts: 8826
Joined: Wed Mar 15, 2000 3:01 am
Location: Seattle

Post by DCrazy »

Here's a PHP page that gets a list of all files in the same directory (except for the PHP page itself):

Code: Select all

<html>
<title>Directory listing</title>
</head>
<body>
<pre>
<?php

$thispage = basename($_SERVER['PHP_SELF'];
foreach(glob('*') as $name)
{
  if($name !== $thispage)
  {
    echo "<a href=\"$name\">$name</a>
  }
";
}
?>
</pre>
</body>
</html>
MD-2389
Defender of the Night
Defender of the Night
Posts: 13477
Joined: Thu Nov 05, 1998 12:01 pm
Location: Olathe, KS
Contact:

Post by MD-2389 »

http://gallery.menalto.com/modules.php? ... file=index

Thats what I'll be using soon to show off my 3D artwork.
User avatar
Iceman
DBB Habitual Type Killer
DBB Habitual Type Killer
Posts: 4929
Joined: Thu Apr 20, 2000 2:01 am
Location: Huntsville, AL. USA
Contact:

Post by Iceman »

ls -a | awk '{print $1"<br>"}' | grep -v "files.html" > files.html
User avatar
Defender
DBB Master
DBB Master
Posts: 5135
Joined: Mon Aug 23, 1999 2:01 am
Location: Boston, MA. USA

Post by Defender »

I wonder if top even knows unix commands? :)

No offense of course. :P
User avatar
Top Wop
DBB Master
DBB Master
Posts: 5104
Joined: Wed Mar 01, 2000 3:01 am
Location: Far from you.
Contact:

Post by Top Wop »

Unfortunately the only thing the server supports is ASP. No php, no CGI, none of that, so it made my job difficult, especially considering I had no choice but to code the rest of the website using FrontPage (eeewww!)

However I did manage to find a VERY nice program which supports ASP and looks very nice and allows you to restrict what file types are to be seen and can hide directories you dont want to show. Its DirList2.1.1 and I highly reccomend it that you check it out. {url=http://fx-scripts.com/dirlist.asp]Linky.[/url]
Post Reply