|
'========================
Sub BuildUploadRequest(RequestBin, UploadRequest)
'========================
'Get the boundary
PosBeg=
PosEnd=InstrB(PosBeg,RequestBin,getByteString(chr()))
boundary=MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos=InstrB(,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 UploadControl
Set UploadControl=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()))
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 + 0
PosEnd=InstrB(PosBeg,RequestBin,getByteString(chr()))
FileName=getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
FileName=Mid(FileName,InStrRev(FileName,"\")+)
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos=InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg=Pos+
PosEnd=InstrB(PosBeg,RequestBin,getByteString(chr()))
'Add content-type to dictionary object
ContentType=getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg=PosEnd+
PosEnd=InstrB(PosBeg,RequestBin,boundary)-
Value=FileName
ValueBeg=PosBeg-
ValueLen=PosEnd-Posbeg
Else
'Get content of object
Pos=InstrB(Pos,RequestBin,getByteString(chr()))
PosBeg=Pos+
PosEnd=InstrB(PosBeg,RequestBin,boundary)-
Value=getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
ValueBeg=0
ValueEnd=0
End If
UploadControl.Add "Value" , Value
UploadControl.Add "ValueBeg" , ValueBeg
UploadControl.Add "ValueLen" , ValueLen
UploadRequest.Add name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub |
|