Solved

asp file read...

Posted on 1999-01-25
4
169 Views
Last Modified: 2013-12-25
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
Comment
Question by:jedimike
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:MasseyM
ID: 1859185
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
 
LVL 2

Author Comment

by:jedimike
ID: 1859186
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
 
LVL 10

Accepted Solution

by:
MasseyM earned 100 total points
ID: 1859187
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
 
LVL 2

Author Comment

by:jedimike
ID: 1859188
Now that's what Im looking for.....
Thank you....
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now