<!--#include file="../lib/filelib.asp"-->
<%
response.write "<title>上传文件至当前文件夹</title>"
response.write "<body bgcolor=""#d6d3ce"" leftmargin=""0"" topmargin=""0"" title = "" 请您遵守国家相关法律法规上传文件。上传前请杀毒,否则系统将会自动删除此文件!"">"
'**start encode**
action=request("a")
if action="ul" then
doupload request.cookies("dazhou.net")("nowpath") & "\"
'checkdiskspace
' response.redirect "fileman.asp"
else
showuploadform
end if
set fso=nothing
'========================
sub showuploadform
'========================
response.write "<dir><form enctype=multipart/form-data name=fmupload method=post action=upload.asp?a=ul><br>"
if request("n")<>"" and isnumeric(request("n")) then session("numuploadfields")=cint(request("n"))
for i=1 to 5
response.write "<input type=file name=file"& i & " size=35><br>"
next
response.write "<br><center><input type=submit value=""开始上传""> <input type='button' value= '取消上传' onclick='window.close()'> "
response.write "</form>"
end sub
'========================
sub doupload(dir)
'========================
'if not application("debugging") then on error resume next
starttime=now
requestbin=request.binaryread(request.totalbytes)
set uploadrequest=createobject("scripting.dictionary")
builduploadrequest requestbin, uploadrequest
keys=uploadrequest.keys
for i=0 to uploadrequest.count - 1
curkey=keys(i)
fname=uploadrequest.item(curkey).item("filename")
if fso.fileexists(dir & fname) then fso.deletefile dir & fname
if fname<>"" and not fso.fileexists(dir & fname) then
value=uploadrequest.item(curkey).item("value")
valuebeg=uploadrequest.item(curkey).item("valuebeg")
valuelen=uploadrequest.item(curkey).item("valuelen")
totalulsize=totalulsize + valuelen
set strm1=server.createobject("adodb.stream")
set strm2=server.createobject("adodb.stream")
strm1.open
strm1.type=1 'binary
strm2.open
strm2.type=1 'binary
strm1.write requestbin
strm1.position=valuebeg
strm1.copyto strm2,valuelen
strm2.savetofile dir & fname,2
set strm1=nothing
set strm2=nothing
end if
next
if now>starttime then response.write("<br><br><br><br><center>上传成功!<br>速度: " & round(totalulsize/1024/datediff("s",starttime,now)) &" 千字节/秒" )
set uploadrequest=nothing
end sub
'========================
sub builduploadrequest(requestbin, uploadrequest)
'========================
'get the boundary
posbeg=1
posend=instrb(posbeg,requestbin,getbytestring(chr(13)))
boundary=midb(requestbin,posbeg,posend-posbeg)
boundarypos=instrb(1,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(34)))
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 + 10
posend=instrb(posbeg,requestbin,getbytestring(chr(34)))
filename=getstring(midb(requestbin,posbeg,posend-posbeg))
filename=mid(filename,instrrev(filename,"\")+1)
'add filename to dictionary object
uploadcontrol.add "filename", filename
pos=instrb(posend,requestbin,getbytestring("content-type:"))
posbeg=pos+14
posend=instrb(posbeg,requestbin,getbytestring(chr(13)))
'add content-type to dictionary object
contenttype=getstring(midb(requestbin,posbeg,posend-posbeg))
uploadcontrol.add "contenttype",contenttype
'get content of object
posbeg=posend+4
posend=instrb(posbeg,requestbin,boundary)-2
value=filename
valuebeg=posbeg-1
valuelen=posend-posbeg
else
'get content of object
pos=instrb(pos,requestbin,getbytestring(chr(13)))
posbeg=pos+4
posend=instrb(posbeg,requestbin,boundary)-2
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
'====================================
function getbytestring(stringstr)
'====================================
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
%>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器