'---------------------- Sub ParseEncodedRequest() Dim PosBeg, PosEnd, boundary, boundaryPos, Pos, Name, PosFile, PosBound, fileName Dim contentType, Value, RequestBin ' Read byte stream RequestBin = Request.BinaryRead( Request.TotalBytes ) 'Get the boundary PosBeg = 1 PosEnd = InStrB( PosBeg, RequestBin, GetByteString( chr(13) ) ) boundary = MidB( RequestBin, PosBeg, PosEnd-PosBeg ) boundaryPos = InStrB( 1, RequestBin, boundary ) 'Get all data inside the boundaries Do Until( boundaryPos = InStrB( RequestBin, boundary & GetByteString( "--" ) ) ) 'Members variable of objects are put in a dictionary object Dim dicFileControl Set dicFileControl = 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 'Get Filename, content-type and content of file PosBeg = PosFile + 10 PosEnd = InStrB( PosBeg, RequestBin, GetByteString( chr(34) ) ) FileName = GetString( MidB( RequestBin, PosBeg, PosEnd-PosBeg ) ) 'Add filename to dictionary object dicFileControl.Add FILE_NAME_ITEM, FileName Pos = InStrB( PosEnd, RequestBin, GetByteString( "Content-Type:" ) ) PosBeg = Pos + 14 PosEnd = InStrB( PosBeg, RequestBin, GetByteString( chr(13) ) ) 'Add content-type to dictionary object ContentType = GetString( MidB( RequestBin, PosBeg, PosEnd-PosBeg ) ) dicFileControl.Add "ContentType", ContentType 'Get content of object PosBeg = PosEnd + 4 PosEnd = InStrB( PosBeg, RequestBin, boundary ) - 2 Value = MidB( RequestBin, PosBeg, PosEnd-PosBeg ) Else '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 ) ) End If 'Add content to dictionary object dicFileControl.Add "Value", Value 'Add dictionary object to main dictionary dicFileStructure.Add name, dicFileControl 'Loop to next object BoundaryPos = InStrB( BoundaryPos + LenB( boundary ), RequestBin, boundary ) Loop End Sub '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