用access数据库时可以显示上传的图片,但是用sql server 2000则不能显示图片,只有一片空白
我用的是windows 2003操作系统和sql server 2000数据库,相关代码如下上传网页(upload.asp)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body leftmargin="0" topmargin="0">
<form name="upform" method="post" action="test_image.asp" enctype="multipart/form-data" >
<input type="hidden" name="act" value="upload">
<input type="hidden" name="filepath" value="images">
<table width="100%" border="0" cellspacing="0" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr>
<td >
<p style="margin-top: 0; margin-bottom: 0" align="center"> </p>
<p style="margin-top: 0; margin-bottom: 0" align="center">
<font size="5" color="#0000FF">上传界面</font></p>
<p style="margin-top: 0; margin-bottom: 0" align="center">文件上传
<input type="file" name="filename" style="width:229; height:23" class="tx1" value="">
<input type="submit" name="Submit" value="提 交" class="tx">
</p>
<p style="margin-top: 0; margin-bottom: 0" align="center">
</td>
</tr>
</table>
</form>
</body>
</html>
存放图像的网页(test_image.asp)
<!--#include file=conn.asp-->
<%
Dim binSize,binData,binImage
binSize=Request.TotalBytes '表单上传数据的二制进大小
binData=Request.BinaryRead(binSize) '从表单中获取二进制数据
vCrLf=ChrB(13) & ChrB(10)
divider=LeftB(binData,InStrB(binData,vCrLf)-1)
dataStart=InStrB(binData,vCrLf & vCrLf)+4
dataEnd=InStrB(datastart+1,binData,divider)-datastart
binImage=MidB(binData,dataStart,dataEnd) '获取图像部分
Set rs=server.CreateObject("ADODB.Recordset")
strsql="select * from photo where id is null"
rs.Open strsql,conn,1,3
rs.AddNew
rs("images").appendchunk binImage
rs.Update
rs.Close
%>
photo_image.asp读取图片网页
<!--#include file=conn.asp-->
<%
Response.Expires = 0
Response.buffer=True
Response.clear
Dim rs,strsql
Response.ContentType="image/*"
Set rs=server.createobject("ADODB.Recordset")
strsql="select * from photo where id=" & Request.QueryString("ID")
rs.open strsql,conn,1,1
fsize=rs("images").actualsize
'Response.BinaryWrite rs("image").GetChunk(7500000)
Response.BinaryWrite rs("images").GetChunk(fsize)
rs.Close
Set rs=nothing
Set conn=nothing
%>
请高手指点下!
显示图片网页(show_image.asp)
<!--#include file=conn.asp-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="image/*; charset=gb2312">
<title>显示数据库中的图片</title>
</head>
<body>
<%
Dim rs,strsql
Set rs=Server.CreateObject("ADODB.Recordset")
strsql="select * from photo"
rs.Open strsql,conn,1,1
%>
<table width="80%" border="1" align="center">
<%Do While Not rs.EOF %>
<tr>
<td width="100">图片标题</td>
<td><%=rs("id")%></td>
</tr>
<tr>
<td>图片</td>
<td><%response.Write("aaaaaaaaaaaa")%></td>
<td><img src=photo_image.asp?id=<%=rs("id")%>></td>
</tr>
<%rs.movenext
Loop
rs.close
set rs=nothing
%>
</table>
</body>
</html>
请高手指点下
以上代码用access数据库时可以实现图片上传显示功能,但是换了sql server 2000数据库则不能任何图片,只有一片空白。