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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

uploading multiple files

Status
Not open for further replies.

chinedu

Technical User
Mar 7, 2002
241
US
I have been trying now, quite unsuccessfully to upload more than one files into our database using aspSmartUpload.
The way we have it spec'ed out is one code can have up to 6 files attached it.

When inserting records into the database, one code say 3333 can be associated with up to 6 files uploaded to the database.
So far, when I try to store more than one files, only one gets inserted.

Here are my 2 files:

Any help, as usual, is greatly appreciated.

Code:
page1:

            <FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="File_Upload1.asp">
            <table width="540" border="0" cellspacing="2" cellpadding="2">
              <tr valign=top>
                <td class="body1"><div align="right">Select Site Code</div></td>
                <td><select name="SiteCode" size="1">
                    <option selected>Choose One:</option>
                    <option>------------------------------------------------</option>
                    <option>1072301</option>
                    <option>1072302</option>
                    <option>1072303</option>
                    <option>1072304</option>
                    <option>1072305</option>
                    <option>1072306</option>
                    <option>1072307</option>
                    <option>1072308</option>
                  </select></td>
              </tr>
              <tr valign=top>
                <td class="body1"><div align="right">Upload PDF</div></td>
                <td><input name="file1" type="file" size="40"></td>
              </tr>
              <tr valign=top>
                <td class="body1"><div align="right">Upload PDF</div></td>
                <td><input name="file2" type="file" size="40"></td>
              </tr>
              <tr valign=top>
                <td class="body1"><div align="right">Upload PDF</div></td>
                <td><input name="file3" type="file" size="40"></td>
              </tr>
              <tr valign=top>
                <td class="body1"><div align="right">Upload PDF</div></td>
                <td><input name="file4" type="file" size="40"></td>
              </tr>

page2:


<%
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
mySmartUpload.Upload
'mySmartUpload.TotalMaxFileSize = 1000000
mySmartUpload.AllowedFilesList = "pdf"
Response.Write("Files allowed=" & mySmartUpload.AllowedFilesList & "<br>")

Set oRs=Server.CreateObject("ADODB.Recordset")
Set DbObjmembers = Server.CreateObject("ADODB.Connection")
DbObjmembers.Open ("counts")

For Each myFile In mySmartUpload.Files
  If Not(myFile.IsMissing) Then
    'get the new filename
    Filename = myFile.fileName
    Filesize = myFile.Size
    contentType = myFile.ContentType

    oRs.open "Select * from TrafficCountsFiles where filename='" & Filename & "';",DbObjmembers,1,3
    myFile.SaveAs("/TrafficCounts/Upload/" & Filename)

    if oRs.eof then
      oRs.addnew
    end if
    oRs("filesize") = Filesize
    oRs("contentType") = contentType
    myFile.FileToField oRs.Fields("filedata")
    oRs("filename") = Filename
    oRs("SiteCode") = mySmartUpload.form("SiteCode")
    oRs.Update

    Response.Redirect "Manage_CountsConfirm.asp"
  Else
    Response.Redirect "Manage_CountssError.asp"
    intCount = intCount + 1
  End If
next
Set mySmartUpload = Nothing
%>

Once again, thank you.

Once again, thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top