er ))
loop</P><P>''开始处理文件数据
Do while lenB(binHTTPHeader)>46
binHeaderData = LeftB(binHTTPHeader, INSTRB( binHTTPHeader, bnCRLF & bnCRLF )-1)
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
UserID=request("UserID")</P><P>Set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
conn.open "DSN=UploadFile"
rs.open "select * from User_File where UserID=''"&UserID&"''",conn,3,3
Response.ContentType = rs("FileContentType")</P><P>lngOffset=0
conChunkSize=1024
lngPictSize=rs("FileContent").ActualSize
Do While lngOffset < lngPictSize
varChunk = rs("FileContent").GetChunk(conChunkSize)
Response.BinaryWrite varChunk
lngOffset = lngOffset + conChunkSize
If lngOffset > lngPictSize Then Exit Do
Loop
rs.close
set rs=Nothing
conn.close
set conn=nothing
%></P><P>就是这些了,希望此方法对大家能有所帮助。:)