—- file name /upaoad.asp/
<%
public function builduploadrequest(strrequestbin)
dim posbeg, posend, boundary, boundarypos
get the boundary
posbeg = 1
posend = instrb(posbeg,strrequestbin,getbytestring(chr(13)))
boundary = midb(strrequestbin,posbeg,posend-posbeg)
boundarypos = instrb(1,strrequestbin,boundary)
get all data inside the boundaries
do until (boundarypos = instrb(strrequestbin,boundary & getbytestring("–")))
members variable of objects are put in a dictionary object
dim uploadcontrol
set uploadcontrol = createobject("scripting.dictionary")
dim pos, name
get an object name
pos = instrb(boundarypos,strrequestbin,getbytestring("content-disposition"))
pos = instrb(pos,strrequestbin,getbytestring("name="))
posbeg = pos + len("name=") + 1
posend = instrb(posbeg,strrequestbin,getbytestring(chr(34)))
name = getstring(midb(strrequestbin,posbeg,posend-posbeg))
dim posfile, posbound, contenttype, value
test if object is of file type
posfile = instrb(boundarypos,strrequestbin,getbytestring("filename="))
posbound = instrb(posend,strrequestbin,boundary)
if posfile <> 0 and posfile < posbound then
get filepathname of the file
posbeg = posfile + len("filename=") + 1
posend = instrb(posbeg,strrequestbin,getbytestring(chr(34)))
filepathname = getstring(midb(strrequestbin,posbeg,posend-posbeg))
add filename(with path) to dictionary object
uploadcontrol.add "filepathname", filepathname
get content-type of the file
pos = instrb(posend,strrequestbin,getbytestring("content-type:"))
posbeg = pos + len("content-type:") + 1
posend = instrb(posbeg,strrequestbin,getbytestring(chr(13)))
contenttype = getstring(midb(strrequestbin,posbeg,posend-posbeg))
add content-type to dictionary object
uploadcontrol.add "contenttype",contenttype
get content of object
posbeg = posend + 4
posend = instrb(posbeg,strrequestbin,boundary)-2
value = midb(strrequestbin,posbeg,posend-posbeg)
else
get content of object
pos = instrb(pos,strrequestbin,getbytestring(chr(13)))
posbeg = pos + 4
posend = instrb(posbeg,strrequestbin,boundary)-2
value = getstring(midb(strrequestbin,posbeg,posend-posbeg))
end if
add content to dictionary object
uploadcontrol.add "value" , value
add dictionary object to main dictionary
set uploadrequest(name) = uploadcontrol
loop to next object
boundarypos = instrb(boundarypos+lenb(boundary),strrequestbin,boundary)
loop
end function
string to byte string conversion
public function getbytestring(strstring)
dim intcount
getbytestring = ""
for intcount = 1 to len(strstring)
getbytestring = getbytestring & chrb(ascb(mid(strstring,intcount,1)))
next
end function
byte string to string conversion
public function getstring(strstring)
dim intcount
getstring = ""
for intcount = 1 to lenb(strstring)
getstring = getstring & chr(ascb(midb(strstring,intcount,1)))
next
end function
%>
