[求助]asp无组件上传然后显示图片时候显示小红叉的问题
基本上按照smth精华区的方法来模仿的
但是在显示图片的时候只有个小红叉
真的是很郁闷
调试好久都没有找到错误,盼各位大侠赐教!
把几个文件贴出来:
select.htm :选择需要上传图片页面
upload.asp :图片上传的处理页面,放到数据库,这个和例子基本一样的
showpic.asp:从数据库读出图片
pic.htm :显示,就是在这里显示的是红色小叉:(
数据库表 因为只是为了验证程序核心所以比较简单
baseinfo
IDNum(primary key) 长整型
Pic OLE对象
-----------------------selectpic.htm----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>selectpic</title>
</head>
<body>
<form action="upload.asp" method="post" enctype="multipart/form-data" name="form1">
<table width="500" border="0" align="center">
<tr>
<td bgcolor="#6666FF">
<div align="center"><font size="4">上传图片(*.bmp,*.jpeg,*.gif)</font></div></td>
</tr>
<tr>
<td><div align="center">
<input type="file" name="file">
</div></td>
</tr>
<tr>
<td><div align="center">
<input type="submit" name="Submit" value="上传">
<input name="reset" type="reset" id="reset" value="重置">
</div></td>
</tr>
</table>
</form>
</body>
</html>
------------------------upload.asp-
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
response.Buffer=true
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
varvalue=midb(formdata,datastart,dataend)
dim objconn
set objconn=server.CreateObject("adodb.connection")
objconn.connectionstring="provider=microsoft.jet.oledb.4.0;"&_
"data source="&server.MapPath("personalinfo.mdb")
objconn.open
dim objrs
set objrs=server.CreateObject("adodb.recordset")
objrs.open "baseinfo",objconn,1,3
objrs.addnew
objrs("IDNum")=2002
objrs("Pic").appendchunk varvalue
objrs.update
objrs.close
set objrs=nothing
objconn.close
set objconn=nothing
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>upload</title>
</head>
<body>
</body>
</html>
-------------------------pic.htm-----
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>pic</title>
</head>
<body>
<img src="showpic.asp?ID=2002" > <img src="warning.gif" width="40" height="40">
</body>
</html>
-------------showpic.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
dim objconn
set objconn=server.CreateObject("adodb.connection")
objconn.connectionstring="provider=microsoft.jet.oledb.4.0;"&_
"data source="&server.MapPath("personalinfo.mdb")
objconn.open
dim objrs
set objrs=server.CreateObject("adodb.recordset")
sql="select * from baseinfo where IDNum="&request("ID")
ohjrs.open sql,objconn,1,1
response.Expires = 0
response.Buffer = True
response.Clear
response.ContentType="image/*"
datasize=objrs("Pic").actualsize
response.BinaryWrite objrs("Pic").getchunk(datasize)
objrs.close
set objrs=nothing
objconn.close
set objconn=nothing
%>