Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

asp file read...

Can someone supply me with an asp page that will list all of the html files that reside in its directory in a clickable menu?  My books dont go into it very well.
0
jedimike
Asked:
jedimike
  • 2
  • 2
1 Solution
 
MasseyMCommented:
Sure, this is a small script that lists the "gif" and "jpg" files (by extension).  you can manipulate it for html pages though.

Index.asp
-----------
<html>
<head><title></title></head>
<body>

<STYLE>
TH      {
      color:Black;
      background:Silver;
      }

</STYLE>

<% SG = Request.QueryString("SG") %>

<%

Set fs = CreateObject("Scripting.FileSystemObject")       'Create the FileSystemObject
If Request.QueryString("F") = "" then
      Response.Write "<FORM METHOD=GET ACTION=index.asp>"
      Response.Write "Which Directory should I start in?&nbsp;<INPUT NAME=""F"">"
      Response.Write "<INPUT TYPE=SUBMIT VALUE=""Browse Directory""><BR>"
      Response.Write "Show Graphics as Thumbnails? <INPUT TYPE=RADIO NAME=""SG"" VALUE=1> Yes | <INPUT TYPE=RADIO NAME=""SG"" VALUE=0 CHECKED> No"
      'Response.Write "<BR>Sample page to display: <INPUT NAME=""sample"" VALUE=""sample.asp"">"
      Response.Write "<BR>View Graphic on CAROS template: <INPUT NAME=""CAROS"" VALUE=""ViewOnCAROS"" TYPE=CHECKBOX>"
      Response.Write "</FORM>"
Else
      Set fold = fs.GetFolder(Request.QueryString("F"))
Response.Write ("<TABLE WIDTH='100%'>")
Response.Write ("<TR><TD>")

 Response.Write ("      <TABLE BORDER WIDTH='100%'>")
 Response.Write ("            <TH ALIGN =LEFT><A STYLE=""text-align:left;"" HREF=" & Request.ServerVariables("HTTP_REFERER") & ">Back</A></TH>")
 Response.Write ("                  <TABLE BORDER WIDTH='100%'>")
 Response.Write ("                        <TH ALIGN = CENTER>" & fold.Path & "</TH>")
 Response.Write ("                  </TABLE>")
 Response.Write ("      </TABLE>")
 Response.Write ("</TD></TR>")

response.Write "<TABLE WIDTH='100%'><TR><TD VALIGn=TOP>"
Response.Write "<TABLE WIDTH='100%'>"
 Set foldCol = fold.SubFolders                              'Create a SubFolders collection
 For Each Y in foldCol                                    'Iterate through it
  Response.Write "<TR>"                              
  Response.Write "<TD><IMG SRC='GRAPHICS/Folder.Gif'><A HREF=index.asp?F=" & Y.Path
  If SG = "1" then Response.Write "&SG=1"
  Response.Write ">&nbsp;" &Y.Name & "</A>"
  Response.Write "</TD>"
  Response.Write "</TR>"
 Next
  Response.Write "</TABLE>"

Response.Write "</TD><TD>"

response.Write "<TABLE WIDTH='100%'>"
 Set foldCol2 = fold.Files                              'Create a Files collection
 For Each Y in foldCol2
 Cur = Cur + 1                                    'Iterate through it
  If Cur >= 6  then Response.Write "<tr>"      
  Response.Write "<td WIDTH='20%'>"
If Right(Y.Path,3) = "gif" or Right(Y.Path,3) = "jpg" then
  If SG = "1" then
      Response.Write "<IMG WIDTH =50 HEIGHT=50  SRC=" & Y.Path &" ><BR>"
  End If
  Response.Write "<A HREF=ViewasBG.asp?G=" & Y.Path & "&CAROS=" & Request("CAROS")
  If SG = "1" then Response.Write "&SG=1"
  Response.Write ">" &Y.Name & "</A>"            'Print the files name
End If
  Response.Write "</td>"
  If Cur >= 5 then
      Response.Write "</tr>"
      Cur = 0
  End If
 Next                                                      
 Response.Write "</table>"
 For Each Y in foldCol                                    'Now lets iterate through the folder collection again
 Next
Response.Write "</TABLE>"
Response.Write "</TD></TR></TABLE>"
End If
%>


ViewAsBG.asp
-------------
<% Graphic = Request.QueryString("G") %>
<% UT = Request.QueryString("UT") %>

<% If Request.QueryString("CAROS") <> "" then %>
      <!-- #Include Virtual="/CRM/CAHeader.asp" -->
      <CENTER><FONT COLOR="RED" SIZE=+3>T E M P L A T E   V I E W</FONT><BR>
            <IMG SRC="<% =request.querystring("G") %>"><BR>
      <A HREF="javascript:history.back(1);">Back</A></CENTER>
      <!-- #Include Virtual="/CRM/CAFooter.asp" -->

<% Else %>
      <% ML=Request.QueryString("ML") %>

      <!-- #Include File="sample2.asp"-->
      <CENTER><A HREF="javascript:history.back(1);">Back</A></CENTER>
<% End If %>
</BODY>
0
 
jedimikeAuthor Commented:
it must be a page where you load it and it lists all the .html files in the directory that it sits in.  Sorry Massey, but I cant use that.  
0
 
MasseyMCommented:
Ok, check this one out...

<html>
<head><title></title></head>
<body>
<%
  Dim fso, f, f1, fc, s
  Set fso = CreateObject("Scripting.FileSystemObject")
      TheFile = Server.MapPath(Request.ServerVariables("SCRIPT_NAME"))
      loc = InStrRev(TheFile,"\")
      TheFile = Left(TheFile,loc)
  Set f = fso.GetFolder(TheFile)
  Set fc = f.Files
  For Each f1 in fc
      if right(f1,5) = ".html" or right(f1,4) = ".htm" then
            s = s & "<A HREF='" & f1.name & "'>" & f1.name & "</A>"
            s = s &  "<BR>"
      End If
  Next
  ShowFileList = s

%>
<%
response.write ShowFileList
%>
</body>
</html>

0
 
jedimikeAuthor Commented:
Now that's what Im looking for.....
Thank you....
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now