|
upload.htm:
<center>
<form name="mainForm" enctype="multipart/form-data" action="process.ASP" method=post>
<input type=file name=mefile>
<input type=submit name=ok value="OK">
</form>
</center>
process.asp:
<body>
<%
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)
dim conn,str
set conn=server.CreateObject("ADODB.connection")
str="driver={microsoft access driver (*.mdb)};dbq=e:\aspstation\database\db3.mdb"
conn.Open str
set rs=server.createobject("ADODB.recordset")
rs.Open "SELECT * FROM images where id is null",conn,1,3
rs.addnew
rs("img").appendchunk mydata
rs.update
rs.close
set rs=nothing
set conn=nothing
%>
</body>
showimg.asp:
<body>
<%
dim conn,str
set conn=server.CreateObject("ADODB.connection")
str="driver={microsoft access driver (*.mdb)};dbq=e:\aspstation\database\db3.mdb"
conn.Open str
dim rs,sql
set rs=server.createobject("ADODB.recordset")
sql="select img from images where id="&trim(request("id"))
rs.open sql,conn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite rs("img").getChunk(7500000)
rs.close
set rs=nothing
set conn=nothing
%>
</body>
上面的代码有错误么?
如何显示我上传的图片?运行showimg.asp可以么? |
|