zhoz blog 重新开张,欢迎继续支持!
Oct
14
前面有人写过PHP储存图片的内容,刚泡完澡,写个以前关于ASP上传直接存到库的来完结今天。
前提情况说明:
表:table 存储字段:photo、类型(OLE 对象)
读图程序:show_photo.asp
1、上传图片
<table border="0" width="100%" cellpadding="0">
<tr>
<td width="74%" nowrap>上传新照片:<input type="file" name="photo"></td>
<td width="26%">
<p align="right"><input type=submit value="上传照片"></p>
</td>
</tr>
</table>
2、储存到库方法
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
sql="select * from table where user='"&request("user")&"'"
rs.open sql,conn,1,3
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
photodata=midb(formdata,datastart,dataend)
rs("photo").appendchunk photodata
rs.update
rs.close
set rs=Nothing
%>
3、删除方法
rs("photo")=Null
4、ASP读取的方法
<img src="show_photo.asp?id=<%=id%>">
show_photo.asp代码:
<!--#include file="conn.asp"-->
<%
Set rs=Server.CreateObject("ADODB.recordset")
sql="select photo from table where id=" & request("id")
rs.open sql,conn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite rs("photo").getChunk(7500000)
rs.close
set rs=nothing
conn.close
set conn=nothing
end If
%>
以上几步,完成了各种操作了。慢慢理解一下,相应有收获。脖子有点痛了,我得去活动活动了。。。
前提情况说明:
表:table 存储字段:photo、类型(OLE 对象)
读图程序:show_photo.asp
1、上传图片
<table border="0" width="100%" cellpadding="0">
<tr>
<td width="74%" nowrap>上传新照片:<input type="file" name="photo"></td>
<td width="26%">
<p align="right"><input type=submit value="上传照片"></p>
</td>
</tr>
</table>
2、储存到库方法
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
sql="select * from table where user='"&request("user")&"'"
rs.open sql,conn,1,3
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
photodata=midb(formdata,datastart,dataend)
rs("photo").appendchunk photodata
rs.update
rs.close
set rs=Nothing
%>
3、删除方法
rs("photo")=Null
4、ASP读取的方法
<img src="show_photo.asp?id=<%=id%>">
show_photo.asp代码:
<!--#include file="conn.asp"-->
<%
Set rs=Server.CreateObject("ADODB.recordset")
sql="select photo from table where id=" & request("id")
rs.open sql,conn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite rs("photo").getChunk(7500000)
rs.close
set rs=nothing
conn.close
set conn=nothing
end If
%>
以上几步,完成了各种操作了。慢慢理解一下,相应有收获。脖子有点痛了,我得去活动活动了。。。
ASP+access常见
asp上传表单提交与接收


Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e10'
[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。
/new/Save_Photo.asp,行 5
行5:rs.open sql,conn,1,3
http://log.zhoz.com/read.php?101