欢迎光临
我们一直在努力

无组件上传文件(1)

建站超值云服务器,限时71元/月

file:upload.asp

<%
author philippe collignon
email phcollignon@email.com

sub builduploadrequest(requestbin)
    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))
            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 = midb(requestbin,posbeg,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))
        end if
        add content to dictionary object
    uploadcontrol.add "value" , value    
        add dictionary object to main dictionary
    uploadrequest.add name, uploadcontrol    
        loop to next object
        boundarypos=instrb(boundarypos+lenb(boundary),requestbin,boundary)
    loop

end sub

string to byte string conversion
function getbytestring(stringstr)
for i = 1 to len(stringstr)
     char = mid(stringstr,i,1)
    getbytestring = getbytestring & chrb(ascb(char))
next
end function

byte string to string conversion
function getstring(stringbin)
getstring =""
for intcount = 1 to lenb(stringbin)
    getstring = getstring & chr(ascb(midb(stringbin,intcount,1)))
next
end function
%>

转自asptoday

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 无组件上传文件(1)
分享到: 更多 (0)