关于图片上传的问题!!!!!哪位大哥帮忙一下都搞了两天了还不行。谢谢!!!
数据库:images.mdb 表:news 字段: id img
上传页:test.asp
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<center>
<form name="mainForm" enctype="multipart/form-data" action="process.asp" method=post>
<input type=file name=me file><br/>
<input type=submit name=ok value="提交">
</form>
</center>
</body>
</html>
保存页:process.asp
<%
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
mydata=midb(formdata,datastart,dataend)
db="images.MDB"
set connGraph=server.CreateObject("ADODB.connection")
connGraph.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
connGraph.Open
set rec=server.createobject("ADODB.recordset")
rec.Open"SELECT*FROM [news] where id is null",connGraph,1,3
rec.addnew
rec("img").appendchunk mydata
rec.update
rec.close
set rec=nothing
set connGraph=nothing
response.redirect"test.asp"
%>
显示页:show.asp
<%
db="images.MDB"
set connGraph=server.CreateObject("ADODB.connection")
connGraph.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
connGraph.Open
%>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
id=1
set rs=server.createobject("adodb.recordset")
sql="select * from news where id="&id
rs.open sql,conGraph,1,1
%>
<tr>
<img src="show_1.asp?id=<%=id%>">
</tr>
</body>
</html>
处理页:show_1.asp
<%
db="images.MDB"
set connGraph=server.CreateObject("ADODB.connection")
connGraph.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
connGraph.Open
set rec=server.createobject("ADODB.recordset")
strsql="select img from news where id="&trim(request("id"))
rec.open strsql,connGraph,1,1
Response.ContentType="image/*"
Response.BinaryWrite rec("img").getChunk(7500000)
rec.close
set rec=nothing
set connGraph=nothing
%>
我现在是能上传,但是不能显示。总是出错,大家帮忙看看哪 里原因呢。
急死人了!!!