Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

File search control for web page

New Here ,
Jun 13, 2007 Jun 13, 2007

Copy link to clipboard

Copied

Hi,
I'm new to dreamweaver and to developing. I have created a web site on my MS 2003 IIS server for a client and all is well. I was asked to add some pages that would allow a user to search a shared file foder and subfolder directory that I created and sem to have hit a wall. What I would think an easy task I guess seems not to be. What I would like to be able to add is a simple search form, drop down or calendar control that would let the user selct the specific folder where their files would be and the without searching through hundres of like-named files, search either by date or have a similar control.
I have been told that using an indexing service would be best and then also told that it would be over kill for this. Any help would be greatly appreciated.
TOPICS
Server side applications

Views

279
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 13, 2007 Jun 13, 2007

Copy link to clipboard

Copied

If you are using ASP then this script will display all the files in the folder you put it in. If you us a form and substitute a file name for the proper variable it will display a file, it also shows the date last modified, you might be able to modify it to do exactly what you want. notice this line <%= objFileItem.DateLastModified %> it gives the date last modified, you could use this also check into the FileSystemObject
'CODE:
<%
Dim strPathInfo, strPhysicalPath
strPathInfo = Request.ServerVariables("PATH_INFO") 'get virtual path of file
strPhysicalPath = Server.MapPath(strPathInfo) 'get physical path of file

Dim objFSO, objFile, objFileItem, objFolder, objFolderContents
Set objFSO = CreateObject("Scripting.FileSystemObject")

set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
%>

<TABLE border="1" cellpadding=10 bordercolor="#3366CC">
<TR Align=center>
<TH align=left>File Name</TH>
<TH>File Type</TH>
<TH>File Size</TH>
<TH>Last Modified</TH>
<TH>View Source</TH>
</TR>
<%
For Each objFileItem In objFolderContents
%>

<TR>
<TD Align=left>
<A HREF="<%= objFileItem.name %>">
<Font Face="Verdana" size="3">
<%= objFileItem.Name %></Font>
</A>
</TD>
<TD align=right>
<FONT FACE="Tahoma" Size"2" >
<%= objFileItem.type %></FONT>
</TD>
<TD align=right>
<FONT FACE="Tahoma" Size="2" >
<%= objFileItem.size %></FONT>
</TD>
<TD align=right>
<FONT FACE="Tahoma" Size="2" >
<%= objFileItem.DateLastModified %></FONT>
</TD>
<TD align=right>
<FONT FACE="Tahoma" Size="2">
<A HREF="DisplaySourceINTDIR.asp?FileName=<%= objFileItem.Name %> ">View Source</A></FONT>
</TD>
</TR>
<%
Next
%>
</TABLE>

' Here is the code for the "DisplaySourceINTDIR.asp" page that displays the source you can delete the link if you want

<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim strPathInfo, strPhysicalPath
strPathInfo = Request.QueryString("FileName")
strPhysicalPath = Server.MapPath(strPathInfo)

Dim objFSO, objFile
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.GetFile(strPhysicalPath)
%>
<HTML>
<HEAD>
<TITLE><%= objFile.Name %> Source Code</TITLE>
</HEAD>
<BODY>
Source Code For: <%= objFile.Name %><HR><P>
<font face=FranklinGothicBookman size=4>
<%
Dim objFileTextStream
Set objFileTextStream = objFile.OpenAsTextStream(ForReading, TristateUseDefault)

Dim strLine
Do While objFileTextStream.AtEndOfStream <> True
strLine = Server.HTMLEncode(objFileTextStream.ReadLine)
strLine = Replace (strLine, Chr(9), "    ")
Response.Write strLine
Response.Write "<BR>" + vbCrLf
Loop
objFileTextStream.Close
%>
</font>
<BR>
<BR>
<HR>
<A HREF="<%= Request.ServerVariables("HTTP_REFERER") %>">Return to Directory</A>
</Body>
</HTML>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2007 Jun 14, 2007

Copy link to clipboard

Copied

LATEST
Thanks so much Mike. I should have also mentioned how new and very green I am to all of this too. I will do my best to digest and give this a try.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines