ASP程序通过FSO文件上传

王朝asp·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

<%

a=Request.TotalBytes

if a>0 Then

Set c=Createobject("adodb.stream")

c.Type=1

c.Open

c.Write Request.BinaryRead(a)

c.Position=0

d=c.Read

e=chrB(13)&chrB(10)

f=Instrb(d,e)

g=Instrb(f+1,d,e)

set h=Createobject("adodb.stream")

h.Type=1

h.Open

c.Position=f+1

c.Copyto h,g-f-3

h.Position=0

h.type=2

h.CharSet="BIG5"

i=h.Readtext

h.close

j=mid(i,InstrRev(i,"\")+1,g)

if instr("jsp/asp/aspx/exe/php/html/htm/...",right(j,len(j)-instr(j,".")))>0 then

session("error")="您要上传不允许的文件"

response.redirect("error.asp")

end if

j=replace(date,"-","")&right(j,len(j)-instr(j,".")+1)

set fso=server.createobject("scripting.filesystemobject")

if fso.FileExists(server.mappath(j)) then

i=1

msg=true

do while msg

m=left(j,instr(j,".")-1)&"("&i&")"&right(j,len(j)-instr(j,".")+1)

if not fso.FileExists(server.mappath(m)) then

j=m

msg=false

end if

i=i+1

loop

end if

set fso=nothing

k=Instrb(d,e&e)+4

l=Instrb(k+1,d,leftB(d,f-1))-k-2

h.Type=1

h.Open

c.Position=k-1

c.CopyTo h,l

h.SaveToFile server.mappath(j),2

end if

%>

<form enctype=multipart/form-data method=post>

<input type=file name=n />

<input name="submit" type=submit value="提交" />

</form>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航