Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    It's correct code

    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

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
    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)


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

    <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>

    </tr>
    <%
    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.Addnew
    RS.Fields("Access Date")= Now
    RS.Fields("File Name")=objItem.Name
    RS.Update
    RS.Close
    Objdb.Close
    Set RS=Nothing
    Set Objdb=Nothing
    Set objfile=objFSO.Getfile(strPath & objItem.Name)
    set opf=objfile.OpenasTextStream(ForReading,-2)
    Response.Write(opf.ReadAll)
    opf.close

    end if%></td>

    </tr>

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

    %>
    </table>
    Attached Thumbnails Attached Thumbnails It's correct code-result.jpg  

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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?)

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by nikkiH View Post
    it have an onlick.
    asp can have onclick method? onclick only has in javascript.right?
    Quote Originally Posted by nikkiH View Post
    (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.
    Last edited by davincith; 09-22-2007 at 03:23 AM. Reason: ...

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    I think you wanted this.

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

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •