如何将无组件上传图片到数据库源码?
如何将无组件上传图片到数据库源码?
******************** One.asp页面表单的Enctype设置.
<form name="form1" method="post" action="one.asp" enctype="multipart/form-data"></form>
******************** Tow.asp页面获取二进制图象信息并上传到数据库.
<% postedData = Request.BinaryRead(Request.TotalBytes)
crlf=ChrB(13) & ChrB(10)
tmpData=LeftB(postedData,CLng(InStrB(postedData,crlf))-1)
dataStart=InStrB(postedData,crlf & crlf)+4
dataEnd=InStrB(dataStart+1,postedData,tmpData)-dataStart
starData=MidB(postedData,dataStart,dataEnd)
Set Rs=Server.CreateObject("Adodb.RecordSet")
Sql="Select * From Picture "
Rs.Open Sql,cn,3,3
Rs.AddNew
Rs("P_Picture").AppendChunk starData
Rs.UpDate
Rs.Close
Set Rs=Nothing%>
******************** Three.asp页面从数据库读取图片信息并显示.
<%
Set Rs=Server.CreateObject("Adodb.RecordSet")
Sql="SELECT * FROM Picture where P_PictureId="&Request("id")
Rs.Open Sql,cn,1,1
%>
<%Response.contenttype="image/gif"%>
<%Response.BinaryWrite Rs("P_Picture")%>
<%Rs.Close
Set Rs=nothing
cn.Close
Set cn=nothing
%>