请教这段文件上传代码的含义,回帖有分,给予详细解释的加赠100分
小弟这里有一段文件上传代码,很好用,就是有些地方不大明白,特来求教,感激涕零!
=====================================
<%
dim contentlen
contentlen=request.totalbytes
if contentlen>102400 then
response.write "文件太大,超过100k,不允许上传。请返回"
else
dim content
content=request.binaryread(request.totalbytes)
'二进制相互转换
Function getByteString(StringStr)
getByteString=""
For i=1 to Len(StringStr)
char=Mid(StringStr,i,1)
getByteString=getByteString&chrB(AscB(char))
Next
End Function
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
dim upbeg,upend,lineone,linetwo,linethree,line1,line2,line3
upbeg=1
upend=instrb(upbeg,content,getbytestring(chr(10)))
lineone=midb(content,upbeg,upend-upbeg)
upbeg=upend+1
line1=lenb(lineone)
upend=instrb(upbeg,content,getbytestring(chr(10)))
linetwo=midb(content,upbeg,upend-upbeg)
upbeg=upend+1
line2=lenb(linetwo)
upend=instrb(upbeg,content,getbytestring(chr(13)))
linethree=midb(content,upbeg,upend-upbeg)
line3=lenb(linethree)
'获得文件名
dim pp,checknametemp,checklen,checkname,filename
pp=instrb(1,linetwo,getbytestring(chr(46)))
checknametemp=rightb(linetwo,line2-pp+1)
checklen=instrb(1,checknametemp,getbytestring(chr(34)))
checkname=getstring(leftb(checknametemp,checklen-1))
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&checkname
'上传文件
dim alllen,upstream,upstreamend,file
alllen=line1+line2+line3+6
set upstream=server.createobject("adodb.stream")
set upstreamend=server.createobject("adodb.stream")
upstream.type=1
upstreamend.type=1
upstream.open
upstreamend.open
upstream.write content
upstream.position=alllen
file=upstream.read(clng(contentlen-alllen-line1-5))
upstreamend.write file
upstreamend.savetofile(server.mappath("/pub/" & filename))
upstream.close
upstreamend.close
set upstream=nothing
set upstreamend=nothing
response.write("已上传")
end if
%>
=====================================
我的问题是:
·1·content=request.binaryread(request.totalbytes)这句话读到content里的内容是什么样的格式?
·2·为什么要设置lineone,linetwo,linethree,line1,line2,line3 这几个变量,它们的变量值是什么?
·3·两个stream对象的相关语句都是什么意思?
·4·为什么要用二进制格式
=====================================
拜托各位!!:)