Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UserID to be submitted with file data

Status
Not open for further replies.

rjn2001

Programmer
Dec 29, 2004
172
0
0
GB
Good Morning, this piece of script submits data to a DB, I am wanting the UserID (strUsername) to be submitted too, so I am needing to persist it to insert.htm, then submit to the DB, which requires the SQL statement to be changed. The problem? I have never used ASP.NET!, and dont have time to learn it all etc. Can anyone help?

Here is the code, it is insert.asp, which gets the filename etc, this is then passed to loader.asp, which does the loading. It is a script from
Code:
<% ' Insert.asp %>
<!--#include file="Loader.asp"-->
<%
  Response.Buffer = True
  ' load object
  Dim load
    Set load = new Loader
    
    ' calling initialize method
    load.initialize
    
  ' File binary data
  Dim fileData
    fileData = load.getFileData("file")
  ' File name
  Dim fileName
    fileName = LCase(load.getFileName("file"))
  ' File path
  Dim filePath
    filePath = load.getFilePath("file")
' File path complete
  Dim filePathComplete
    filePathComplete = load.getFilePathComplete("file")
  ' File size
  Dim fileSize
    fileSize = load.getFileSize("file")
  ' File size translated
  Dim fileSizeTranslated
    fileSizeTranslated = load.getFileSizeTranslated("file")
  ' Content Type
  Dim contentType
    contentType = load.getContentType("file")
  ' No. of Form elements
  Dim countElements
    countElements = load.Count
  ' Value of text input field "fname"
  Dim fnameInput
    fnameInput = load.getValue("fname")
  ' Value of text input field "lname"
  Dim lnameInput
    lnameInput = load.getValue("lname")
  ' Value of text input field "profession"
  Dim profession
    profession = load.getValue("profession")  
    
  ' destroying load object
  Set load = Nothing
%>

<html>
<head>
  <title>Inserts Images into Database</title>
  <style>
    body, input, td { font-family:verdana,arial; font-size:10pt; }
  </style>
</head>
<body>
  <p align="center">
    <b>Inserting Binary Data into Database</b><br>
    <a href="../menu.asp?">To return to the Blue Resourcing menu, click here</a>
  </p>
  
  <table width="700" border="1" align="center">
  <tr>
    <td>File Name</td><td><%= fileName %></td>
  </tr><tr>
    <td>File Path</td><td><%= filePath %></td>
  </tr><tr>
    <td>File Path Complete</td><td><%= filePathComplete %></td>
  </tr><tr>
    <td>File Size</td><td><%= fileSize %></td>
  </tr><tr>
    <td>File Size Translated</td><td><%= fileSizeTranslated %></td>
  </tr><tr>
    <td>Content Type</td><td><%= contentType %></td>
  </tr><tr>
    <td>No. of Form Elements</td><td><%= countElements %></td>
  </tr><tr>
    <td>First Name</td><td><%= fnameInput %></td>
  </tr><tr>
    <td>Last Name</td><td><%= lnameInput %></td>
  </tr>
  <tr>
    <td>Profession</td><td><%= profession %></td>
  </tr>
  </table><br><br>
  
  <p style="padding-left:220;">
  <%= fileName %> data received ...<br>
  <%
    ' Checking to make sure if file was uploaded
    If fileSize > 0 Then
    
      ' Connection string
      Dim connStr
        connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
        connStr = connStr & Server.MapPath("FileDB.mdb")
    
      ' Recordset object
      Dim rs
        Set rs = Server.CreateObject("ADODB.Recordset")
        
        rs.Open "Files", connStr, 2, 2
        
        ' Adding data
        rs.AddNew
          rs("File Name") = fileName
          rs("File Size") = fileSize
	  rs("UserID") = UserID
          rs("File Data").AppendChunk fileData
          rs("Content Type") = contentType
          'rs("First Name") = fnameInput
          'rs("Last Name") = lnameInput
          'rs("Profession") = profession
        rs.Update
        
        rs.Close
        Set rs = Nothing
        
      Response.Write "<font color=""green"">File was successfully uploaded..."
      Response.Write "</font>"
    Else
      Response.Write "<font color=""brown"">No file was selected for uploading"
      Response.Write "...</font>"
    End If
      
      
    If Err.number <> 0 Then
      Response.Write "<br><font color=""red"">Something went wrong..."
      Response.Write "</font>"
    End If
  %>
  </p>
  
  <br>
  <table border="0" align="center">
  <tr>
  <form method="POST" enctype="multipart/form-data" action="Insert.asp">
  <td>First Name :</td><td>
    <input type="text" name="fname" size="40" ></td>
  </tr>
  <td>Last Name :</td><td>
    <input type="text" name="lname" size="40" ></td>
  </tr>
  <td>Profession :</td><td>
    <input type="text" name="profession" size="40" ></td>
  </tr>
  <td>File :</td><td>
    <input type="file" name="file" size="40"></td>
  </tr>
  <td> </td><td>
    <input type="submit" value="Submit"></td>
  </tr>
  </form>
  </tr>
  </table>

</body>
</html>

Richard Noon
 
I would suggest posting this question in the ASP forum (forum333) as it is all in ASP and you have stated you don't have time to learn ASP.NET.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Thanks, my only reason for doing this, is because it is an ASP.NET script.
The code you posted above isn't ASP.NET - it's ASP.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top