<%
Function TextToBinary(text)
For i=1 to Len(text)
character=Mid(text,i,1)
TextToBinary=TextToBinary & ChrB(Asc(character))
Next
End Function
Function BinaryToText(Binary)
BinaryToText=""
For i=1 to LenB(Binary)
character=MidB(Binary,i,1)
BinaryToText=BinaryToText & Chr(AscB(character))
Next
End Function
Set uploaddata=CreateObject("Scripting.Dictionary")
data=Request.BinaryRead(Request.TotalBytes)
posend=InStrB(1,data,TextToBinary(Chr(13)))
header=MidB(data,1,posend-1)
endheader=header&TextToBinary("_")
pos_header=1
pos_endheader=InStrB(1,data,endheader)
Do While pos_header<>pos_endheader
Set sub_uploaddata=CreateObject("Scripting.Dictionary")
pos_name=InStrB(pos_header,data,TextToBinary("name="))
pos_namebegin=pos_name+6
pos_nameend=InStrB(pos_namebegin,data,TextToBinary(Chr(34)))
name=BinaryToText(MidB(data,pos_namebegin,pos_nameend-pos_namebegin))
pos_file=InStrB(pos_nameend,data,TextToBinary("filename="))
enddata=InStrB(pos_nameend,data,header)
If (pos_file<>0)And(pos_file<enddata) Then
pos_filebegin=pos_file+10
pos_fileend=InStrB(pos_filebegin,data,TextToBinary(Chr(34)))
filename=BinaryToText(MidB(data,pos_filebegin,pos_fileend-pos_filebegin))
sub_uploaddata.Add "filename",filename
pos_content=InStrB(pos_fileend,data,TextToBinary("Content-Type:"))
pos_contentbegin=pos_content+14
pos_contentend=InStrB(pos_contentbegin,data,TextToBinary(Chr(13)))
contenttype=BinaryToText(MidB(data,pos_contentbegin,pos_contentend-pos_contentbegin))
sub_uploaddata.Add "contenttype",contenttype
pos_valuebegin=pos_contentend+4
pos_valueend=InStrB(pos_valuebegin,data,header)-2
Value=BinaryToText(MidB(data,pos_valuebegin,pos_valueend-pos_valuebegin))
sub_uploaddata.Add "value",value
Else
pos_valuebegin=pos_nameend+4
pos_valueend=InStrB(pos_valuebegin,data,header)-2
Value=BinaryToText(MidB(data,pos_valuebegin,pos_valueend-pos_valuebegin))
sub_uploaddata.Add "value",value
End If
uploaddata.Add name,sub_uploaddata
pos_header=InStrB(pos_header+LenB(header),data,header)
Loop
%>