<% Class MultiRequest Private dicRequest Private Sub Class_Initialize() Set dicRequest = ParseEncodedRequest End Sub Public Default Property Get Form(sVar) Set var = New MultiRequestVariable If dicRequest.Exists(sVar) Then With var .Found = True .Name = dicRequest(sVar)("Name") .IsFile = dicRequest(sVar)("IsFile") .Value = dicRequest(sVar)("Value") If .IsFile Then iPos = InStrRev(.Value, "\") If iPos > 0 Then .Value = Mid(.Value, iPos+1) End If iPos = InStrRev(.Value, ".") If iPos > 0 Then .FileExtension = LCase(Mid(.Value, iPos+1)) End If .FileContents = dicRequest(sVar)("FileContents") .FileContentType = dicRequest(sVar)("FileContentType") End If End With Else var.Found = False End If Set Form = var End Property End Class Class MultiRequestVariable Private sValue Public Found Public Name Public IsFile Public FileContents Public FileContentType Public FileExtension Public Default Property Get Value() Value = sValue End Property Public Property Let Value(sNewValue) sValue = sNewValue End Property End Class Function ParseEncodedRequest() Dim PosBeg, PosEnd, boundary, boundaryPos, Pos, Name, PosFile, PosBound, fileName Dim contentType, Value, RequestBin, dicVar, dicRequest ' Read byte stream RequestBin = Request.BinaryRead( Request.TotalBytes ) 'Get the boundary PosBeg = 1 PosEnd = InStrB( PosBeg, RequestBin, GetByteString( Chr(13) ) ) If PosEnd < PosBeg Then Set ParseEncodedRequest = Server.CreateObject("Scripting.Dictionary") Exit Function End If boundary = MidB( RequestBin, PosBeg, PosEnd-PosBeg ) boundaryPos = InStrB( 1, RequestBin, boundary ) ' Initialize request object Set dicRequest = Server.CreateObject( "Scripting.Dictionary" ) 'Get all data inside the boundaries Do Until( boundaryPos = InStrB( RequestBin, boundary & GetByteString( "--" ) ) ) 'Members variable of objects are put in a dictionary object Set dicVar = Server.CreateObject( "Scripting.Dictionary" ) 'Get an object name Pos = InStrB( BoundaryPos, RequestBin, GetByteString( "Content-Disposition" ) ) Pos = InStrB( Pos, RequestBin, GetByteString( "name=" ) ) PosBeg = Pos + 6 PosEnd = InStrB( PosBeg, RequestBin, GetByteString( Chr(34) ) ) Name = GetString( MidB( RequestBin, PosBeg, PosEnd-PosBeg ) ) PosFile = InStrB( BoundaryPos, RequestBin, GetByteString( "filename=" ) ) PosBound = InStrB( PosEnd, RequestBin, boundary ) 'Test if object is of file type If PosFile <> 0 And ( PosFile < PosBound ) Then dicVar.Add "Name", Name dicVar.Add "IsFile", True 'Get Filename, content-type and content of file and add filename to dictionary object PosBeg = PosFile + 10 PosEnd = InStrB( PosBeg, RequestBin, GetByteString( Chr(34) ) ) FileName = GetString( MidB( RequestBin, PosBeg, PosEnd-PosBeg ) ) dicVar.Add "Value", FileName dicVar.Add "FileName", Mid(FileName, InStrRev(Replace(FileName, "/", "\"), "\")+1) 'Add content-type to dictionary object Pos = InStrB( PosEnd, RequestBin, GetByteString( "Content-Type:" ) ) PosBeg = Pos + 14 PosEnd = InStrB( PosBeg, RequestBin, GetByteString( Chr(13) ) ) ContentType = GetString( MidB( RequestBin, PosBeg, PosEnd-PosBeg ) ) dicVar.Add "FileContentType", ContentType 'Get content of object PosBeg = PosEnd + 4 PosEnd = InStrB( PosBeg, RequestBin, boundary ) - 2 Value = MidB( RequestBin, PosBeg, PosEnd-PosBeg ) dicVar.Add "FileContents", Value Else dicVar.Add "Name", Name dicVar.Add "IsFile", False 'Get content of object Pos = InStrB( Pos, RequestBin, GetByteString( Chr(13) ) ) PosBeg = Pos + 4 PosEnd = InStrB( PosBeg, RequestBin, boundary ) - 2 Value = GetString( MidB( RequestBin, PosBeg, PosEnd-PosBeg ) ) dicVar.Add "Value", Value End If 'Add dictionary object to main dictionary dicRequest.Add Name, dicVar 'Loop to next object BoundaryPos = InStrB( BoundaryPos + LenB( boundary ), RequestBin, boundary ) Loop ' Return dictionary of files Set ParseEncodedRequest = dicRequest End Function 'Byte string to string conversion Function GetString(StringBin) Dim intCount GetString = "" For intCount = 1 to LenB( StringBin ) GetString = GetString & Chr( AscB( MidB( StringBin, intCount, 1 ) ) ) Next End Function 'String to byte string conversion Function GetByteString( StringStr ) Dim i, char For i = 1 to Len( StringStr ) char = Mid( StringStr, i, 1 ) GetByteString = GetByteString & ChrB( AscB( char ) ) Next End Function %>