Web Listings of Folder Contents

What is the programming strings in any web language to do the following.

Drop Down menu box, Gives a list of potential master level folders

Click on one of the options and in another window next to it lists all files currently in that folder.

But i also want it to search and list, not just take filenames and locations from a text file. So that if anyone drops files into the folder on the server the web page will just list all the files avaliable and if you refresh it will also include any additional files found since it last did its auto background no interactive search.

Need anymore details please let me know...

Have at it guys and gals!!
rabelleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RouchieCommented:
I've wrote some code to achieve this a while back using ASP (Classic).  It consists of 3 pages - 1 to list the drives, 1 to list the folders and files in the root directory of the chosen drive, and 1 to list all files and folders in any other directory.
I know it could be improved but I never got the time, and anyway it works okay.

======================================================================
go.asp
------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<title>File Finder</title>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">

<p>Please choose the drive to would like to request file structure from:</p>

<form action="listall.asp" method="post" name="choosedrive">
<select name="theDrive">
      <%
      ' dynamically create a list of drives on the system
      ' -------------------------------------------------
      Set fs = Server.CreateObject("Scripting.FileSystemObject")
      For each thing in fs.Drives %>

            <% if thing.IsReady then %>
            
                  <% ' trim excess colon and backslash to leave drive letter %>
                  <option value="<%=thing%>" class="bluetext" name="theDrive"><%=thing%></option>
                  
            <% end if %>
      
      <% Next %>
</select>

<input type="submit" value="Next" class="blue">
</form>
</body>
</html>

<%
' clear up memory
Set fs = Nothing
%>
======================================================================



======================================================================
listall.asp
------------------------------------------------------------------------------------------------------------------------------
<%
' capture selected drive from last page
' -------------------------------------
DIM theDrive
theDrive = Server.HTMLEncode(Request.form("theDrive"))
%>

<html>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">

<h2><%=theDrive%></h2>

<p>
<a href="go.asp" class="fileresult"><img src="images/drive.gif" border="0" /> Return to drive selection</a>
</p>

<hr>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="350" nowrap class="titlecell">Folder/File name</td>
<td width="110" nowrap class="titlecell">Type</td>
<td width="50"  nowrap class="titlecell">Size</td>
<td width="150" nowrap class="titlecell">Created</td>
<td width="150" nowrap class="titlecell">Last Modified</td>
</tr>

<%
' list folders in directory
' -------------------------
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set folderlist = fs.Getfolder(theDrive)
For each thing in folderlist.Subfolders%>

      <tr>
      <td nowrap>
          <img src="images/folder.gif" />
          <a href="foldercontent.asp?folder=<%=server.URLEncode(thing)%>" class="fileresult">
          <%=thing.Name%>
            </a>
      </td>
      <td nowrap>
            &nbsp;
      </td>
      <td nowrap>
            &nbsp;
      </td>
      <td nowrap>
            &nbsp;
      </td>
      <td nowrap>
            &nbsp;
      </td>
      </tr>
<% Next %>


<%
' list files in directory
' -----------------------
Set filelist = fs.Getfolder(theDrive)
For each thing in filelist.Files %>

      <tr>
      <td nowrap>
          <img src="images/file.gif" /><%=thing.Name%>
      </td>
      <td nowrap class="description">
            <%=thing.Type%>
      </td>
      <td nowrap class="description">
            <%=thing.Size%>
      </td>
      <td nowrap class="description">
            <%=thing.DateCreated%>
      </td>
      <td nowrap class="description">
            <%=thing.DateLastAccessed%>
      </td>
      </tr>
<% Next %>

</table>

</body>
</html>


<%
' clear up
' --------
Set fs = Nothing
Set folderlist = Nothing
Set filelist = Nothing
Set theDrive = Nothing
%>
======================================================================



======================================================================
foldercontent.asp
------------------------------------------------------------------------------------------------------------------------------
<%
' Get folder name from query string
' ---------------------------------
DIM folderToList
folderToList = Server.HTMLEncode(Request.queryString("folder"))
folderToList = Replace(folderToList,"&","&amp;")


' Create file system access object
' --------------------------------
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set folder = fs.Getfolder(folderToList)
%>


<html>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">

<h2><%=folder%></h2>

<p>
<%' check to see if parent folder is root folder, and if true point to drive selector page
'   --------------------------------------------------------------------------------------
if folder.IsRootFolder then %>
  <a href="go.asp" class="fileresult"><img src="images/drive.gif" border="0" /> Return to drive selection</a>
<% else %>
  <a href="foldercontent.asp?folder=<%=folder.ParentFolder%>" class="fileresult"><img src="images/parentfolder.gif" border="0" /> Return to parent folder</a>
<% end if %>
</p>


<hr>


<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="300" nowrap class="titlecell">Folder/File name</td>
<td width="110" nowrap class="titlecell">Type</td>
<td width="50"  nowrap class="titlecell">Size</td>
<td width="150" nowrap class="titlecell">Created</td>
<td width="150" nowrap class="titlecell">Last Modified</td>
</tr>

<%
' list folders in directory using file access object
' --------------------------------------------------
For each thing in folder.Subfolders%>

      <tr>
      <td nowrap>
          <img src="images/folder.gif" />
          <a href="foldercontent.asp?folder=<%=Server.URLEncode(thing)%>" class="fileresult">
            <%=thing.Name%>
            </a>
      </td>
      <td nowrap>
            &nbsp;
      </td>
      <td nowrap>
            &nbsp;
      </td>
      <td nowrap>
            &nbsp;
      </td>
      <td nowrap>
            &nbsp;
      </td>
      </tr>

<% Next

' list files in directory using file access object
' ------------------------------------------------
Set filelist = fs.Getfolder(folderToList)
For each thing in filelist.Files %>

      <tr>
      <td nowrap>
          <img src="images/file.gif" /><%=thing.Name%>
      </td>
      <td nowrap class="description">
            <%=thing.Type%>
      </td>
      <td nowrap class="description">
            <%=thing.Size%>
      </td>
      <td nowrap class="description">
            <%=thing.DateCreated%>
      </td>
      <td nowrap class="description">
            <%=thing.DateLastAccessed%>
      </td>
      </tr>

<% Next %>

</table>
</body>
</html>

<%
' clear up
Set folderToList = Nothing
Set fs = Nothing
Set folder = Nothing
Set filelist = Nothing
%>
======================================================================

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.