如何显示出用asp+access2000上传的图片?就差一小步,郁闷!
别人现成的代码: 现在贴出来: 一、设计数据库testimg.mdb 为方便调试,设计表imgurl,其中两个字段:id(自动编号、关键字)、img(OLE对象) 二、连接数据库文件conn.asp <% db_path="testimg.mdb" setconn=server.CreateObject("ADODB.connection") connstr="driver={MicrosoftAccessDriver(*.mdb)};dbq="&server.MapPath(db_path) conn.openconnstr %> 三、提供上传图片的表单页面upload.html <formaction="upload.asp"method="post"enctype="multipart/form-data"> <inputtype="file"name="imgurl"> <inputtype="submit"name=okvalue="ok"> </form> 四、接受数据并添加记录页upload.asp <!--#includefile="conn.asp"--> <% 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 mydata=midb(formdata,datastart,dataend) setrs=server.createobject("ADODB.recordset") rs.open"SELECT*FROMimgurl",conn,3,3 rs.addnew rs("img").AppendChunkmyData rs.update rs.close setrs=nothing setconn=nothing response.redirect"index.asp" %> 五、提取数据库表中图片字段内容以做显示图片页showimg.asp <!--#includefile="conn.asp"--> <% setrs=server.createobject("ADODB.recordset") sql="select*fromimgurlwhereid="&trim(request("id")) rs.opensql,conn,1,1 Response.ContentType="image/*" Response.BinaryWriters("img").getChunk(8000000) rs.close setrs=nothing setconn=nothing %> 六、显示图片的index.asp <!--#includefile="conn.asp"--> <% strsql="select*fromimgurl" setrs=server.createobject("ADODB.recordset") rs.openstrsql,conn,1,1 dountilrs.eof whatid=rs("id") %> <imgsrc="showimg.asp?id=<%=whatid%>"> <% rs.movenext loop%>