'---- file name /upaoad.asp/
1
2Public Function BuildUploadRequest(strRequestBin)
3Dim PosBeg, PosEnd, boundary, boundaryPos
4'Get the boundary
5PosBeg = 1
6PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(13)))
7boundary = MidB(strRequestBin,PosBeg,PosEnd-PosBeg)
8boundaryPos = InstrB(1,strRequestBin,boundary)
9
10'Get all data inside the boundaries
11Do until (boundaryPos = InstrB(strRequestBin,boundary & getByteString("--")))
12'Members variable of objects are put in a dictionary object
13Dim UploadControl
14Set UploadControl = CreateObject("Scripting.Dictionary")
15
16Dim Pos, Name
17'Get an object name
18Pos = InstrB(boundaryPos,strRequestBin,getByteString("Content-Disposition"))
19Pos = InstrB(Pos,strRequestBin,getByteString("name="))
20PosBeg = Pos + Len("name=") + 1
21PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(34)))
22Name = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
23
24Dim PosFile, PosBound, ContentType, Value
25'Test if object is of file type
26PosFile = InstrB(BoundaryPos,strRequestBin,getByteString("filename="))
27PosBound = InstrB(PosEnd,strRequestBin,boundary)
28
29If PosFile <> 0 AND PosFile < PosBound Then
30'Get FilePathName of the file
31PosBeg = PosFile + Len("filename=") + 1
32PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(34)))
33FilePathName = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
34
35'Add filename(with path) to dictionary object
36UploadControl.Add "FilePathName", FilePathName
37
38'Get Content-Type of the file
39Pos = InstrB(PosEnd,strRequestBin,getByteString("Content-Type:"))
40PosBeg = Pos + Len("Content-Type:") + 1
41PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(13)))
42ContentType = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
43
44'Add content-type to dictionary object
45UploadControl.Add "ContentType",ContentType
46
47'Get content of object
48PosBeg = PosEnd + 4
49PosEnd = InstrB(PosBeg,strRequestBin,boundary)-2
50Value = MidB(strRequestBin,PosBeg,PosEnd-PosBeg)
51Else
52'Get content of object
53Pos = InstrB(Pos,strRequestBin,getByteString(chr(13)))
54PosBeg = Pos + 4
55PosEnd = InstrB(PosBeg,strRequestBin,boundary)-2
56Value = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
57End If
58
59'Add content to dictionary object
60UploadControl.Add "Value" , Value
61
62'Add dictionary object to main dictionary
63Set UploadRequest(Name) = UploadControl
64
65'Loop to next object
66BoundaryPos = InstrB(BoundaryPos+LenB(boundary),strRequestBin,boundary)
67Loop
68End Function
69
70'String to byte string conversion
71Public Function getByteString(strString)
72Dim intCount
73
74getByteString = ""
75
76For intCount = 1 to Len(strString)
77getByteString = getByteString & chrB(AscB(Mid(strString,intCount,1)))
78Next
79End Function
80
81'Byte string to string conversion
82Public Function getString(strString)
83Dim intCount
84
85getString = ""
86
87For intCount = 1 to LenB(strString)
88getString = getString & chr(AscB(MidB(strString,intCount,1)))
89Next
90End Function