二文件上传,才30行代码

网络整理 - 07-26
<%
' upload.asp
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就是表单名啦~
%>