Click to See Complete Forum and Search --> : Directory Listing in HTML
Whisper
May 22nd, 2000, 09:06 PM
Something about the number of responses here tells me I wont get an answer anytime in the near future... But i'm gonna ask anyway...
I'm making a webpage for file downloads, and I want it to always be current with the files that are available in the directory.
I figured if there was some way to get a HTML listing of the files in the directory, it would really take a load off. Anyone have a clue?
<~Whisper~>
noone
May 24th, 2000, 03:29 AM
Do you have access to any server side programming/scripting for this page?
Whisper
May 24th, 2000, 06:35 AM
Yes. I have full access to everythin... Fire away!! :)
jwilde1
May 25th, 2000, 12:27 AM
Does full access mean you have a cgi-bin directory that you can put scripts in that can be executed from a client browser?
noone
May 25th, 2000, 06:33 AM
If you can run ASP pages this might help you out:
http://www.asptoday.com/articles/19990319.htm
If you have rights to run ASP scripts and create an instance of the "Scripting.FileSystemObject" object then this code should be good for you:
<%@ Language=VBScript %>
<html>
<head>
<title>News & Bulletins</title>
</head>
<body bgcolor="#FFFFFF" link="#FF9A09" text="#000099" vlink="#000099">
<font face="Arial">
<%
dim Files, Folder, fsoFile
set fsoFile = Server.CreateObject("Scripting.FileSystemObject")
set Folder=fsoFile.GetFolder(server.MapPath("."))
set files = Folder.Files
if files.count<>0 then
for each file in files
if lcase(right(file,5)) = ".html" then
%>
<a href="<%=server.urlpathencode(fsoFile.GetBaseName(file))%>.html"><%=fsoFile.GetBaseName(file)%></a><br>
<%
end if
next
end if
set fsoFile = Nothing
%>
</font>
</body>
</html>
As it stands the code only lists ".html" files and hides the file extension (but I'm sure a smart person like you can sort that out! :) )
As for the colour scheme... :) Lets just say that it looks ok when you see the rest of the site I created it for (corporate colours and all that).
Chiow!
[Edited by matthewralston on 05-26-2000 at 09:49 AM]
parksie
Jun 5th, 2000, 11:54 PM
depending on how the server's set up, if you just don't put an index.html file (or something similar) in a folder, you either get a directory listing generated by the client browser, or a message telling you it's forbidden to browse. If the former, then you're fine, if the latter, then the clever people here have already told you what to do.
Whisper
Jun 6th, 2000, 01:59 AM
Verry nice, matthewralston... I had originaly used the "no-html file in the directory" (tacky) method of creating a file listing, but it seems this works very efficiently :)
Thanx a million...
~~Whisper~~
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.