SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old August 14th, 2003, 07:33 AM
thagizmo thagizmo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 1 thagizmo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question ASPPure Upload xpert Problem

Hi Guys, Hope you can help me out here.

I am using ASP Pure Upload for uploading 3 files in a form and putting their names in a dbase. So far no problem. In the same form i also have a huge list of checkboxes which the user can check randomly.

In the procesing script after the submit i want to check those checkboxes if they are checked and if so, add theiur value to another table in the dbase. This used to go like this:

for each FormField in Request.Form
' do stuff
next

The problem is, that when i inserted the functions to be able to upload files with the form, i had to change the request.Form to Uploader.Form so the above loop became:


for each FormField in Uploader.Form
' do stuff
next

Now here comes the problem.....the 'UPLOADER.FORM' is not the same thing as the 'REQUEST.FORM'. The second loop will not go through all the items in the form.....I have also tried things like:
- Uploader.Form.Items
- Uploader.Files

etc. But i cannot seem to access the loose form items variably.

it CAN access each item if i give it the name like: UPLOADER.FORM("checkbox1")

but since the '1' can be a random number (dbase primary key) there is no way to do it like this.

So the summarise, does anyone know how i can use the:

for each FormField in Request.Form
' do stuff
next

in the situation that i have now, with the uploader class i used. I added the class code of the uploader object. it seems to be a well known thingie. Tnx in advance for any help guys!


======CODE OF THE CLASS BELOW ===========


PHP Code:
Class FileUploader
    
Public  Files
    
Private mcolFormElem

    
Private Sub Class_Initialize()
         
Set Files Server.CreateObject("Scripting.Dictionary")
         
Set mcolFormElem Server.CreateObject("Scripting.Dictionary")
    
End Sub
    
     
Private Sub Class_Terminate()
         If 
IsObject(FilesThen
              Files
.RemoveAll()
              
Set Files Nothing
         End 
If
         If 
IsObject(mcolFormElemThen
              mcolFormElem
.RemoveAll()
              
Set mcolFormElem Nothing
         End 
If
    
End Sub

    
Public Property Get Form(sIndex)
         
Form ""
         
If mcolFormElem.Exists(LCase(sIndex)) Then Form mcolFormElem.Item(LCase(sIndex))
    
End Property

    
Public Default Sub Upload()
         
Dim biDatasInputName
         Dim nPosBegin
nPosEndnPosvDataBoundsnDataBoundPos
         Dim nPosFile
nPosBound

         biData 
Request.BinaryRead(Request.TotalBytes)
         
nPosBegin 1
         nPosEnd 
InstrB(nPosBeginbiDataCByteString(Chr(13)))
         
         If (
nPosEnd-nPosBegin) <= 0 Then Exit Sub
          
          vDataBounds 
MidB(biDatanPosBeginnPosEnd-nPosBegin)
         
nDataBoundPos InstrB(1biDatavDataBounds)
         
         Do 
Until nDataBoundPos InstrB(biDatavDataBounds CByteString("--"))
              
               
nPos InstrB(nDataBoundPosbiDataCByteString("Content-Disposition"))
              
nPos InstrB(nPosbiDataCByteString("name="))
              
nPosBegin nPos 6
              nPosEnd 
InstrB(nPosBeginbiDataCByteString(Chr(34)))
              
sInputName CWideString(MidB(biDatanPosBeginnPosEnd-nPosBegin))
              
nPosFile InstrB(nDataBoundPosbiDataCByteString("filename="))
              
nPosBound InstrB(nPosEndbiDatavDataBounds)
              
               If 
nPosFile <> And  nPosFile nPosBound Then
                   Dim oUploadFile
sFileName
                   Set oUploadFile 
= New UploadedFile
                   
                   nPosBegin 
nPosFile 10
                   nPosEnd 
=  InstrB(nPosBeginbiDataCByteString(Chr(34)))
                   
sFileName CWideString(MidB(biDatanPosBeginnPosEnd-nPosBegin))
                   
oUploadFile.FileName Right(sFileNameLen(sFileName)-InStrRev(sFileName"\"))

                   nPos = InstrB(nPosEnd, biData, CByteString("
Content-Type:"))
                   nPosBegin = nPos + 14
                   nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
                   
                   oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                   
                   nPosBegin = nPosEnd+4
                   nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                   oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
                   
                   If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
              Else
                   nPos = InstrB(nPos, biData, CByteString(Chr(13)))
                   nPosBegin = nPos + 4
                   nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                   If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
              End If

              nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
         Loop
    End Sub

    'String to byte string conversion
    Private Function CByteString(sString)
         Dim nIndex
         For nIndex = 1 to Len(sString)
            CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))
         Next
    End Function

    'Byte string to string conversion
    Private Function CWideString(bsString)
         Dim nIndex
         CWideString =""
         For nIndex = 1 to LenB(bsString)
            CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1))) 
          Next
    End Function
End Class

Class UploadedFile
    Public ContentType
    Public FileName
    Public FileData
    
     Public Property Get FileSize()
         FileSize = LenB(FileData)
    End Property

    Public Sub SaveToDisk(sPath)
         Dim oFS, oFile
         Dim nIndex
    
          If sPath = "" Or FileName = "" Then Exit Sub
         If Mid(sPath, Len(sPath)) <> "" Then sPath = sPath & ""
    
          Set oFS = Server.CreateObject("
Scripting.FileSystemObject")
         If Not oFS.FolderExists(sPath) Then Exit Sub
         
         Set oFile = oFS.CreateTextFile(sPath & FileName, True)
         
         For nIndex = 1 to LenB(FileData)
             oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
         Next

         oFile.Close
    End Sub
    
     Public Sub SaveToDatabase(ByRef oField)
         If LenB(FileData) = 0 Then Exit Sub
         
         If IsObject(oField) Then
              oField.AppendChunk FileData
         End If
    End Sub

End Class


%> 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > ASPPure Upload xpert Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway