还有一个问题是,在show.asp加个循环后,我添加3张图片,每张一条记录,也加3条记录的文字进去,但是只出现第一条的记录的文字,图片就可以有几张,也就是加上去的几条记录上的图片都可以显示,文字就只有第一条记录的文字而已,别的,显示不了.ACCESS,表里有id,自动编号,texe1,类型文本,text2,类型文本,img,类型OLE
upload1.asp<% @ language=vbscript %>
<html>
<head>
<meta name="VI60_defaultClientScript" content="VBScript">
<title> File Upload </title>
<script ID="clientEventHandlersVBS" LANGUAGE="vbscript">
<!--
Sub form2_onsubmit
form1.submit
End Sub
-->
</script>
</head>
<body>
<form name="form1" ENCTYPE="multipart/form-data" ACTION="upimage.asp" METHOD="POST" target="_blank">
请选择上传的图片: <br>
<input NAME="picture" TYPE="FILE"> <br>
</form>
<form name="form2" action="uptext.asp" method="post">
<input type="text" name="text1"><br>
<input type="text" name="text2"><br>
<input type="submit" value="提交">
</form>
</body>
</html>
uptext.asp
<%@ language=vbscript%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>无标题文档</title>
</head>
<body>
<%
Set strconn=Server.CreateObject("ADODB.Connection")
strconn.Open "Dbq=" & Server.Mappath("wwwlink.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
text1=request.form("text1")
text2=request.form("text2")
response.write text1
response.write text2
set rs=Server.CreateObject("adodb.recordset")
sql="SELECT top 1 * FROM imgtable ORDER BY id DESC"
rs.Open sql,strconn,1,3
rs("text1")=text1
rs("text2")=text2
rs.Update
rs.Close
%>
</body>
</html>
upimage.asp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
response.buffer=true
FormSize = Request.TotalBytes
FormData = Request.BinaryRead( FormSize )
function ImageUp(formsize,formdata)
bncrlf=chrb(13) & chrb(10)
divider=leftb(formdata,instrb(formdata,bncrlf)-1)
datastart=instrb(formdata,bncrlf&bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
imageup=midb(formdata,datastart,dataend)
end function
Image=ImageUp (FormSize,Formdata)
Set strconn=Server.CreateObject("ADODB.Connection")
strconn.Open "Dbq=" & Server.Mappath("wwwlink.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
set rs=server.CreateObject("adodb.recordset")
sql="SELECT * FROM imgtable"
rs.Open sql,strconn,1,3
rs.AddNew
rs("img").appendchunk Image
rs.Update
rs.Close
response.contenttype="image/*"
response.binarywrite imageup(formsize,formdata)
%>
</body>
</html>
picshow.asp
<%@ Language=VBScript %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
Response.Expires = 0
Response.buffer=True
Response.clear
Set strconn=Server.CreateObject("ADODB.Connection")
strconn.Open "Dbq=" & Server.Mappath("wwwlink.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
id=trim(Request.form("id"))
set rs=server.CreateObject("adodb.recordset")
sql="SELECT * FROM imgtable where id=id"
rs.Open sql,strconn,1,3
response.contenttype="image/*"
Response.BinaryWrite rs("img").getChunk(7500000)
%>
</body>
</html>
show.asp
<%@ Language=VBScript %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
Set strconn=Server.CreateObject("ADODB.Connection")
strconn.Open "Dbq=" & Server.Mappath("wwwlink.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
set rs=Server.CreateObject("adodb.recordset")
sql="SELECT * FROM imgtable ORDER BY id DESC"
rs.Open sql,strconn,1,3
%>
以下是你的上传资料。<br>
文本一:<% Response.Write rs("text1") %><br>
文本二:<% Response.Write rs("text2") %><br>
你的图像:
<img src=picshow.asp?id=<%=rs("id")%>>
</body>
</html>