Write:
1: Read the gif image file into memory (a variable strtemp).
2: Write to the database.
dim bintmp() as byte
dim conn as adodb.connection
dim rs as adodb.recordset
dim strsql as string
set conn = new adodb.connection
set rs = new adodb.recordset
conn.open "db"
strsql = "select * from tbimage"
rs.open strsql, conn, 1, 3
openfile ("bayshore.jpg")
'Please implement the openfile function yourself
rs.addnew
rs.fields("image").appendchunk bintmp
rs.update
Read and display:
show.asp:
<%
dim p
dim l
l = 8192
dim conn,rs,strsql
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source=" &server.mappath(".") & "/db2.mdb;persist security info=false"
set rs=server.createobject("adodb.recordset")
strsql = "select * from tbimage"
response.contenttype = "image/gif"
'important!
rs.open strsql,conn,1,1
rs.movelast
do
p = rs("image").getchunk(l)
response.binarywrite p
if lenb(p) < l then exit do
loop
%>
In html:
<image src=show.asp>