upload.htm 上传图片的表单
<html>
<body>
<center>
<form name="mainForm" enctype="multipart/form-data" action="upimage.asp" method=post>
<input type=file name=mefile><br>
<input type=submit name=ok value="OK">
</form>
</center>
</body>
</html>
upimage.asp 把图片处理后存进数据库
<html>
<%
formsize=request.TotalBytes
formdata=request.BinaryRead(formsize)
bncrlf=chrb(13)&chrb(10)
divider=leftb(formdata,clng(instrb(formdata,bncrlf))-1)
datastart=instrb(formdata,bncrlf&bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
imageup=midb(formdata,datastart,dataend)
set rs=server.createobject("adodb.recordset")
sql="select * from picture order by id desc"
con="dbq=" & server.MapPath("picture.mdb") & ";driver={Microsoft Access Driver (*.mdb)};"
rs.open sql,con,1,3
rs.addnew
rs("picture").appendchunk imageup
rs.update
%>
<body>
<img src=outimage.asp?id=<%=rs("id")%>>
</body>
</html>
outimage.asp 把图片从数据库中提取出来
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<%
id=trim(request.querystring("id"))
set rs=server.createobject("adodb.recordset")
con="dbq=" & server.MapPath("picture.mdb") & ";driver={Microsoft Access Driver (*.mdb)};"
sql="select * from picture where id="&id
rs.open sql,con,1,1
if not rs.eof then
Response.ContentType = "image/*"
Response.BinaryWrite rs("picture")
end if
%>
<body>
</body>
</html>
ACCESS数据库
id 自动编号
picture OLE对象
我能把图片存进数据库,但提取不出来,请高手指点一下,谢谢