Asp下实现多表单域无组件文件上传的实例(2)


        Next 
    End If 
    bin2str = ccc 
End Function </P><P>
varByteCount = Request.TotalBytes
bnCRLF = chrB( 13 ) & chrB( 10 )
binHTTPHeader=Request.BinaryRead(varByteCount)        
Divider = LEFTB( binHTTPHeader,  INSTRB( binHTTPHeader, bnCRLF ) - 1 )</P><P>'开始读非文件域的数据
Do while lenB(binHTTPHeader)>46

    binHeaderData = LeftB(binHTTPHeader, INSTRB( binHTTPHeader, bnCRLF & bnCRLF )-1)
    strHeaderData=bin2str(binHeaderData)</P><P>    lngFieldNameStart=Instr(strHeaderData,"name="&chr(34))+Len("name="&chr(34))
    lngFieldNameEnd=Instr(lngFieldNameStart,strHeaderData,chr(34))

    
    strFieldName=Mid(strHeaderData,lngFieldNameStart,lngFieldNameEnd-lngFieldNameStart)
    strFieldName=Trim(strFieldName)
    strFieldName=Replace(strFieldName,vbcrlf,vbnullstring)

        '判断文件数据时候开始
    If strComp(strFieldName,"FileUploadStart",1)=0 Then
        binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))
        exit do
    End if

    DataStart = INSTRB( binHTTPHeader, bnCRLF & bnCRLF ) + 4 
    DataEnd = INSTRB( DataStart + 1, binHTTPHeader, divider ) - DataStart</P><P>    binFieldValue=MIDB( binHTTPHeader, DataStart, DataEnd )
    strFieldValue=bin2str(binFieldValue)
    strFieldValue=Trim(strFieldValue)
    strFieldValue=Replace(strFieldValue,vbcrlf,vbnullstring)</P><P>    '非文件上传域变量赋值
    execute strFieldName&"="""&strFieldValue&""""

        
    binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))

loop</P><P>'开始处理文件数据
Do while lenB(binHTTPHeader)>46

    
    binHeaderData = LeftB(binHTTPHeader, INSTRB( binHTTPHeader, bnCRLF & bnCRLF )-1)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2695.html