Asp下实现多表单域无组件文件上传的实例(3)
strHeaderData=bin2str(binHeaderData)
'读取上传文件的Content-Type
lngFileContentTypeStart=Instr(strHeaderData,"Content-Type:")+Len("Content-Type:")
strFileContentType=Trim(Mid(strHeaderData,lngFileContentTypeStart))
strFileContentType=Replace(strFileContentType,vbCRLF,vbNullString)
'读取上传的文件名
lngFileNameStart=Instr(strHeaderData,"filename="&chr(34))+Len("filename="&chr(34))
lngFileNameEnd=Instr(lngFileNameStart,strHeaderData,chr(34))
strFileName=Mid(strHeaderData,lngFileNameStart,lngFileNameEnd-lngFileNameStart)
strFileName=Trim(strFileName)
strFileName=Replace(strFileName,vbCRLF,vbNullString)
'读取上传文件数据
DataStart = INSTRB( binHTTPHeader, bnCRLF & bnCRLF ) + 4
DataEnd = INSTRB( DataStart + 1, binHTTPHeader, divider ) - DataStart
If strFileName<>"" Then
binFieldValue=MIDB( binHTTPHeader, DataStart, DataEnd )
'将上传的文件写入数据库
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=abc"
SQL="select * from User_File"
set rs=server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,3,3
rs.addnew
rs("UserID")=UserID
rs("FileContentType")=strFileContentType
rs("FileContent").AppendChunk binFieldValue
rs.update
rs.close
set rs=Nothing
conn.Close
set conn=Nothing
End if
binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))
loop
%>
4。下载用户上传的文件
<%
Response.Buffer = true
Response.Clear
内容版权声明:除非注明,否则皆为本站原创文章。