关于上传图片的问题
我已经把图片用binary格式放进数据库了,但是我不知道怎么调出来显示在页面上,
请高手帮我写下详细源码
我的数据库是SQLServer的,数据表名是productor,内容如下
字段名称 类型 描述
id int(Identity) 主键值
picture image 用来保存图片数据
我用的读取方法是
showimg.asp文件
<%
num = trim(request( "id "))
Sql = "select * from productor where id = "&num
Rs.open Sql,Con,1,1
Response.ContentType= "image/* "
Response.BinaryWriterec( "img ").getChunk(7500000)
Rs.close
Con.close
Set Rs = nothing
Set Con = nothing
%>
<img src= "showimg.asp?id= <%=rs( "id ")%> ">
但是显示不出来图片啊,请帮我下,到底要怎么写,是不是代码要放在两个页面中?
------解决方案--------------------字段是picture,怎么用了img?
上面的部分代码换成下面的代码看看
Rs.open Sql,Con,1,3
Response.ContentType= "image/* "
Response.BinaryWriterec Rs( "picture ")
------解决方案--------------------asp中如何显示数据中二进制值的图片
<img src= "inc/product_showimg.asp?product_id= <%=(rs.Fields.Item( "product_id ").Value)%> " >
'***********************
'
product_showimg.asp
'***********************
<%
Response.Buffer = True
Response.Expires = 0
Response.Clear
Response.ContentType = "image/gif "
%>
<%
set rs = Server.CreateObject( "ADODB.Recordset ")
rs.ActiveConnection = MM_conn_STRING
rs.Source = "SELECT product_smallpic FROM products WHERE product_id = " & Request( "product_id ")
rs.CursorType = 1
rs.CursorLocation = 2
rs.LockType = 3
rs.Open()
s = rs( "product_smallpic ").ActualSize
data = rs( "product_smallpic ").GetChunk(s)
Response.BinaryWrite data
%>
<%
rs.Close()
%>