access在ASP图片无法显示出来,求帮忙 50
弄完就这效果,无法显示图片。一、设计数据库testimg.mdb为方便调试,设计表imgurl,其中两个字段:id(自动编号、关键字)、img(OLE对象)二、连接数据库...
弄完就这效果,无法显示图片。
一、设计数据库testimg.mdb为方便调试,设计表imgurl,其中两个字段:id(自动编号、关键字)、img(OLE 对象)二、连接数据库文件conn.asp<%db_path="testimg.mdb"set conn=server.CreateObject("ADODB.connection")connstr="driver={Microsoft Access Driver (*.mdb)};dbq="&server.MapPath(db_path)conn.open connstr%> 三、提供上传图片的表单页面upload.html<form action="upload.asp" method="post" enctype="multipart/form-data"> <input type="file" name="imgurl"> <input type="submit" name=ok value="ok"></form> 四、接受数据并添加记录页upload.asp<!--#include file="conn.asp"--><%formsize=request.totalbytesformdata=request.binaryread(formsize)bncrlf=chrB(13)&chrB(10)divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)datastart=instrb(formdata,bncrlf&bncrlf)+4dataend=instrb(datastart+1,formdata,divider)-datastartmydata=midb(formdata,datastart,dataend)set rs=server.createobject("ADODB.recordset")rs.open "SELECT * FROM imgurl",conn,3,3rs.addnewrs("img").AppendChunk myDatars.updaters.closeset rs=nothingset conn=nothingresponse.redirect "index.asp"%> 五、提取数据库表中图片字段内容以做显示图片页showimg.asp<!--#include file="conn.asp"--><%set rs=server.createobject("ADODB.recordset")sql="select * from imgurl where id="&trim(request("id"))rs.open sql,conn,1,1Response.ContentType="image/*"Response.BinaryWrite rs("img").getChunk(8000000)rs.closeset rs=nothingset conn=nothing%> 六、显示图片的index.asp<!--#include file="conn.asp"--><%strsql="select * from imgurl"set rs=server.createobject("ADODB.recordset")rs.open strsql,conn,1,1do until rs.eofwhatid=rs("id")%><img src="showimg.asp?id=<%=whatid%>"><%rs.movenextloop%> 展开
一、设计数据库testimg.mdb为方便调试,设计表imgurl,其中两个字段:id(自动编号、关键字)、img(OLE 对象)二、连接数据库文件conn.asp<%db_path="testimg.mdb"set conn=server.CreateObject("ADODB.connection")connstr="driver={Microsoft Access Driver (*.mdb)};dbq="&server.MapPath(db_path)conn.open connstr%> 三、提供上传图片的表单页面upload.html<form action="upload.asp" method="post" enctype="multipart/form-data"> <input type="file" name="imgurl"> <input type="submit" name=ok value="ok"></form> 四、接受数据并添加记录页upload.asp<!--#include file="conn.asp"--><%formsize=request.totalbytesformdata=request.binaryread(formsize)bncrlf=chrB(13)&chrB(10)divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)datastart=instrb(formdata,bncrlf&bncrlf)+4dataend=instrb(datastart+1,formdata,divider)-datastartmydata=midb(formdata,datastart,dataend)set rs=server.createobject("ADODB.recordset")rs.open "SELECT * FROM imgurl",conn,3,3rs.addnewrs("img").AppendChunk myDatars.updaters.closeset rs=nothingset conn=nothingresponse.redirect "index.asp"%> 五、提取数据库表中图片字段内容以做显示图片页showimg.asp<!--#include file="conn.asp"--><%set rs=server.createobject("ADODB.recordset")sql="select * from imgurl where id="&trim(request("id"))rs.open sql,conn,1,1Response.ContentType="image/*"Response.BinaryWrite rs("img").getChunk(8000000)rs.closeset rs=nothingset conn=nothing%> 六、显示图片的index.asp<!--#include file="conn.asp"--><%strsql="select * from imgurl"set rs=server.createobject("ADODB.recordset")rs.open strsql,conn,1,1do until rs.eofwhatid=rs("id")%><img src="showimg.asp?id=<%=whatid%>"><%rs.movenextloop%> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询