:: Forum >>

Directory listing

Hi,

I did some searching, and I couldn't find a topic on this. I'm wondering if it's possible to use this to list the contents of multiple directories, i.e. can it make one list to show the files in several folders on the client's computer? I'm not talking about sending out private information, just giving the client the ability to browse the contents of his/her own computer at specific places.

Thanks!

WHS
WHS
Friday, February 18, 2005
i used the following vbscript. it was a real bugger for someone who does not know vbscript. i pieced together code from about 5 different websites. hope it helps. this will not run on apache web server. i am learning javascript and hoping that is can do the same thing

directory listing

<html>

<%
' script by [email protected]


dim category,subfolders,fso,categoryfile, categoryfolderlist, s, x

category = Request.QueryString("category")

categoryfile=Server.MapPath("pix/"&category&"/")
Set fso = CreateObject("Scripting.FileSystemObject")

set categoryfolderlist = fso.GetFolder(categoryfile)

Set SubFolders = categoryfolderlist.SubFolders


if subfolders.count=0 then
%>
<header>
<title>
David & Melanie's Photo Gallery - 404 Not Found
</title>

<body>
<br><h3><p align="center"><b>Whoops! How did you get here???</b></p></h3><br><br>
</body>
</html>
<%
else
%>
<header>
<title>
David & Melanie's Photo Gallery
</title>
</header>

<body bgcolor="#C6E2FF">
<br>
There are / will be too many links to put onto the main page, so here are the baby photos.
<br><br><br>
<p align="center"><b>Brian Sashen Lucas</b></p><br>
<%
For Each SubFolder In SubFolders
s=split(subfolder.name,". ")
%>
<a href="detailed.asp?category=baby/<%=subfolder.name%>&bgcolor=C6E2FF"><%=s(1)%></a><br>
<%
Next

%>
</body>
</html>
<%
end if
%>

file listing

<html>

<%@ Language=VBScript %>
<%
dim fso, photono, filelist_array, filecount, category, test, categoryfile, categoryfilelist
dim checkfilename, showname, ordered, checkorder, height, textcolor

category = Request.QueryString("category")
bgcolor = Request.QueryString("bgcolor")
showname = Request.QueryString("showname")
ordered = Request.QueryString("ordered")

photono=1
categoryfile=Server.MapPath("pix/"&category&"/")
Set fso = CreateObject("Scripting.FileSystemObject")

<!--17 -->

set categoryfilelist = fso.GetFolder(categoryfile)

set filelist_array = categoryfilelist.Files

filecount = filelist_array.count

if (filecount = 0) then
%>
<html>
<header>
<title>
David And Melanie Photo Gallery
</title>

<!-- 33 -->

<body>
<br><h3><p align="center"><b>Coming Soon...Under Construction (or my upload failed. come back soon)</b></p></h3><br><br>
</body>
</html>
<%
else
%>
<header>
<title>
David And Melanie Photo Gallery - <%=category%>
</title>

<body bgcolor=#<%=bgcolor%>>
<h3><p align="center"><b> <%=category%></b></p></h3>

<!-- 50 -->

<table border=1 width="100%">
<tr>
<%
for each file in filelist_array
filename = file.name

checkfilename=split(filename,".")

if (checkfilename(1)="jpg" or checkfilename(1)="JPG") then

if (ordered=1) then
checkorder=split(filename,"^")
checkfilename=split(checkorder(1),".")
end if

filename=categoryfile&"\"&filename

Set fso = CreateObject("Scripting.FileSystemObject")

<!-- 71 -->
textcolor="000000"
height="175"

if (category="David And Melanies Wedding") then
textcolor="aaaaaa"
height="150"
end if
%>
<td height="200"><p align=center><a href="pix/<%=category%>/<%
if (ordered=1) then response.write (checkorder(0)&"^") end if
%><%=checkfilename(0)%>.<%=checkfilename(1)%>"><img border="0" src="pix/<%=category%>/
<%
if (ordered=1) then response.write (checkorder(0)&"^") end if
%><%=checkfilename(0)%>.<%=checkfilename(1)%>" height="<%=height%>"></a><br>
<% if (showname="1") then
%>
<font color="#<%=textcolor%>"><%=checkfilename(0)%>
<%
end if

select case photono
case 4
Response.write "</tr><tr>"
case 8
Response.write "</tr><tr>"
case 12
Response.write "</tr><tr>"
case 16
Response.write "</tr><tr>"
case 20
Response.write "</tr><tr>"
case 24
Response.write "</tr><tr>"
case 28
Response.write "</tr><tr>"
case 32
Response.write "</tr><tr>"
case 36
Response.write "</tr><tr>"
case 40
Response.write "</tr><tr>"
case 44
Response.write "</tr><tr>"
case 48
Response.write "</tr><tr>"
case 52
Response.write "</tr><tr>"
case 56
Response.write "</tr><tr>"
case 60
Response.write "</tr><tr>"
case 64
Response.write "</tr><tr>"
case 68
Response.write "</tr><tr>"
case 72
Response.write "</tr><tr>"
case 76
Response.write "</tr><tr>"
case 80
Response.write "</tr><tr>"
case else

End Select

photono=photono+1

end if


next
%>

</tr>
</table>
</body>
</html>
<%
end if



' <td width="50%" height="350"><p align=center><a href="lc00001.jpg"><img border="0" src="lc00001.jpg" height="300"></a><br>Full Picture</p></td>
' <td width="50%" height="350"><p align=center><a href="lc00001a.jpg"><img border="0" src="lc00001a.jpg" height="300"></a><br>Mechanism</p></td>
' </tr><tr>
' <td width="50%" height="350"><p align=center><a href="lc00001b.jpg"><img border="0" src="lc00001b.jpg" height="300"></a><br>Clock Face</p></td>
' <td width="50%" height="350"><p align=center><a href="lc00001c.jpg"><img border="0" src="lc00001c.jpg" height="300"></a><br>Side View</p></td>


%>

[email protected]
Saturday, May 14, 2005

This topic is archived.


Back to support forum

Forum search