ASP上传图片并保存到access数据库某个表中的源码,能详细解释一下源码的意思

 我来答
cxkwelcome
2012-06-19 · TA获得超过204个赞
知道答主
回答量:184
采纳率:0%
帮助的人:172万
展开全部
给你个例子:
1、access表有以下几个字段:
id 自动编号,
filename 文本,
type 文本,
what OLE对象,
size 数字

2、上传页面(upfile.htm):
文件上传<br />
<form action="upload.asp" method="post" enctype="multipart/form-data">
文件 <input type="file" name="file1" /> <input type="submit" value="上传" />
</form>

3、提交页面(upload.asp):
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--#include file="UpLoad_Class.asp"-->
<%
dim upload
set upload = new AnUpLoad
upload.Exe = "*"
upload.MaxSize = 2 * 1024 * 1024 '2M
upload.charset = "utf-8"
upload.GetData()
if upload.ErrorID>0 then
response.Write upload.Description
else
dim file
for each frm in upload.forms("-1")
response.Write frm & "=" & upload.forms(frm) & "<br />"
next
set file = upload.files("file1")
if not(file is nothing) then
set conn = server.CreateObject("ADODB.connection")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&server.mappath("./")&"\db.mdb"
set rs = server.createobject("adodb.recordset")

rs.Open "pic", conn, 1, 3, 2
rs.addnew
rs.fields("filename") = file.LocalName
rs.fields("type") = file.ContentType
rs.fields("what") = file.GetBytes()
rs.fields("size") = file.Size
rs.update
Response.Redirect "listpic.asp"

end if
end if
set upload = nothing
%>

4、其中引用了UpLoad_Class.asp文件,是艾恩无组件上传类,网上搜一下就能找到。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式