Solved

Contentspage

Posted on 1998-10-02
4
138 Views
Last Modified: 2013-12-25
Can anyone tell me how I could make some kind of script that creates a page with a list of links based on the files in the same directory and their titles. I use WinNT and IIS4. So I guess it could be done both in JavaScript or ASP.

Tor Olaf
0
Comment
Question by:toros
4 Comments
 
LVL 4

Expert Comment

by:mcix
ID: 1855408
With ASP you can use the File System Object.  I think I have some code that does that sort of thing...
0
 
LVL 4

Expert Comment

by:raoool
ID: 1855409
Crude solution, but...

With IIs, set Directory Browsing Allowed for that directory (via management console). When a browser navigates to that directory without specifying a legal file name (and a default page does not exist) the server will return a linked list of filenames.

Presenting the <TITLE> would require some scripting.
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 100 total points
ID: 1855410
Here is a program that I wrote in ASP to list all the graphics in a directory and then send them to a script so I could see how they look as backgrounds:

GO2.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>"
      Response.Write "Which Directory should I start in?&nbsp;<INPUT NAME=""F"" VALUE="":\"">"
      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> No"
      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=/>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=go2.asp?F=" & Y.Path
  If SG = "1" then Response.Write "&SG=1"
  Response.Write ">" &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
  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") %>
<% UT = 1 %>
<% If UT = "1" then %>
<% ML=Request.QueryString("ML") %>
<!-- #Include Virtual="/Sample.Asp"-->
<% End If %>
<%
Set fs = CreateObject("Scripting.FileSystemObject")
%>

</BODY>


SAMPLE.ASP
----------------------------------------------------
anything you want.. I use all the colors so I can see how they look against the background..

0
 

Author Comment

by:toros
ID: 1855411
Thanks. It gave me some ideas about how to solve it. If somebody's interrested, a solution that works follows :

<%@ LANGUAGE="VBSCRIPT" %>

<html>
<head><title></title></head>
<body>

<%
PRIVATE sub intoFold(newfold)

 set fold = fileSYSObj.GetFolder(newfold)                  
 Set foldCol2 = fold.Files                              
 
For Each Y in foldCol2                                    
      Response.Write "<A HREF='" & newfold & "\" & Y.Name & "'>"            
      ReadAllTextFile(newfold & "\" & Y.Name)
Next                                                      
      
end sub

Function ReadAllTextFile(FilePath)
  Const ForReading = 1, ForWriting = 2
  Dim fso, f
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.OpenTextFile(FilePath, ForReading)
  ReadAllTextFile =  f.ReadAll
  WriteTitle(ReadAllTextFile)
End Function

Function WriteTitle(Text)
      Dim MyString,MyString2
      MyString = Split(Text, "<TITLE>", -1, 1)
      ' MyString(0) contains Trash.
      ' MyString(1) contains the next splitstring.
      MyString2 = Split(MyString(1),"</TITLE>",-1,1)
      ' MyString2(0) contains the title
      Response.Write MyString2(0) & "</A><BR>"
End Function

Set fileSYSObj = CreateObject("Scripting.FileSystemObject")       
intoFold("d:\test")                                    
%>
</body>
</html>
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 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

14 Experts available now in Live!

Get 1:1 Help Now