欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

二文件上传,才30行代码

程序员文章站 2022-08-14 23:51:35
<% upload.function intmin(n,y)    if n0 then  &nbs...
<%
upload.
function intmin(n,y)
    if n<y and n>0 then
        intmin=int(n)
    elseif y>0 then
        intmin=int(y)
    else
        intmin=n
    end if
end function

function getformvalue(name)
    dim formsize,formdata,dataheader,datastart,dataend,formnamestart,formnameend,formname,firstfilter
    formsize=request.totalbytes()
    formdata=request.binaryread(formsize)
    firstfilter=true
        for i=1 to len(name)
            tmp=tmp&chrb(ascb(mid(name,i,1)))
        next
    name=tmp
    dataend=0
    datastart=0
    do while formsize>0
        formdata=rightb(formdata,formsize-dataend-datastart+1)
        formsize=formsize-dataend-datastart+1
        dataheader=leftb(formdata,instrb(formdata,chrb(13)&chrb(10))-1)
        datastart=instrb(formdata,chrb(13)&chrb(10)&chrb(13)&chrb(10))+4
        dataend=instrb(datastart+1,formdata,dataheader)-datastart
            if datastart<0 or dataend<=0 then exit do
        filtereddata=midb(formdata,datastart,dataend-1)
        formnamestart=instrb(formdata,chrb(ascb("n"))&chrb(ascb("a"))&chrb(ascb("m"))&chrb(ascb("e"))&chrb(ascb("="))&chrb(ascb("""")))+6
        formnameend=intmin(instrb(formnamestart,formdata,chrb(13)&chrb(10))-formnamestart-1,instrb(formnamestart,formdata,chrb(ascb(";")))-formnamestart-1)
        formname=midb(formdata,formnamestart,formnameend)
            if name=formname then
                getformvalue=filtereddata
                exit function
            end if
    loop
getformvalue=name&" not found!"
end function
response.binarywrite(getformvalue("loadfromfile"))这个loadfromfile就是表单名啦~
%>