View Full Version : It's correct code

09-21-2007, 06:45 PM
I write asp to get a input value that is filename or some part of file name in Server Folder.When asp find out it,It will show files that match with user's input value and "open"button(as a picture that I attach in this thread).when user click some of the files,it will save access date and file name into database file(Ms Access) and then open it.But When I click button,It doesn't open the file.

Please edit my code.I have to send it On Tuesday.

This my asp code

Dim strPath
Dim objFSO
Dim objFolder
Dim objItem
Dim strQuery Dim objfile,opf
strPath = "C:\upload\"

strQuery = Request.QueryString("filesearch")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPath)

Contents of <strong><%= strPath %></strong> that match your query:

<table border="5" bordercolor="green" cellspacing="0" cellpadding="2">
<tr bgcolor="#006600">
<td><font color="#FFFFFF"><strong>File&nbsp;Name:</strong></font></td>
<td width="50%"></td>

For Each objItem In objFolder.Files โชว์ไฟล์ที่ตรงกับค่าที่ userพิมพ์ครับ
If InStr(1, objItem.Name, strQuery, vbTextCompare) <> 0 Then
<tr bgcolor="#CCFFCC">
<td align="left" ><%= objItem.Name %></td>

<td><%if request.form("openf")="" then%>
<form action="openfilesv.asp" method="post"><input type="button" name="openf"value="Open it"></form>
<% else
Set Objdb = Server.CreateObject("ADODB.Connection")
Objdb.Open "provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=c:\inetpub\wwwroot\mywebproject\fileinfo.mdb;"
Set RS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM [FileInfo]"
RS.Open SQL,Objdb,1,3
RS.Fields("Access Date")= Now
RS.Fields("File Name")=objItem.Name
Set RS=Nothing
Set Objdb=Nothing
Set objfile=objFSO.Getfile(strPath & objItem.Name)
set opf=objfile.OpenasTextStream(ForReading,-2)

end if%></td>


End If
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
set opf=nothing
set objfile=nothing
set objFSO=nothing


09-21-2007, 09:05 PM
The button is not a submit button, nor does it have an onlick.
So, it won't do much other than look pretty.

(is this homework?)

09-22-2007, 04:20 AM
it have an onlick.

asp can have onclick method? onclick only has in javascript.right?

(is this homework?)
It's a project

Are you quite sure that you say makes my code correct?
Please help.I have stuck only this page.

09-24-2007, 04:28 PM
I think you wanted this.

<input type="submit" name="openf" value="Open it">