第二部分:写入数据库(这是修改的主要内容)upload.asp页内容
<%
'----------------------------------------------------------
'***************** 风声无组件上传类 2.0 *****************
'用法举例:批量上传
'该例主要说明默认模式下FileItem在批量上传中的应用
'以上传附件为例
'下面是上传程序(upload.asp)的代码和注释
'**********************************************************
'----------------------------------------------------------
OPTION EXPLICIT
Server.ScriptTimeOut=5000
%>
<!--#include FILE="UpLoadClass.asp"-->
<!--#include file="conn.asp" -->
<%
dim request2,formPath,formName,intCount,intTemp,protitle,protext,showindex,proclass,upfile,rs,sql
'建立上传对象
set request2=new UpLoadClass
'设置文件允许的附件类型为gif/jpg/rar/zip
request2.FileType="gif/jpg"
'设置服务器文件保存路径
request2.SavePath="../UpLoadFile/"
'打开对象
request2.open()
%>
<html>
<head>
<title>批量上传——风声无组件上传类</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="db_sc8.css" rel="stylesheet" type="text/css">
</head>
<body>
<br>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td class="text12">
<%
'显示类版本
'response.Write("<br>"&request2.version&"<br>")
'显示文章标题
response.Write("<br>文章标题:"&request2.Form("proTitle"))
'----列出所有上传了的文件开始----
'将记录写入数据库,此为自己新增部分
Set Rs =Server.CreateObject("Adodb.RecordSet")
Sql="select * from product"
rs.open sql,conn,1,3
intCount=0
for intTemp=1 to Ubound(request2.FileItem)
'获取表单文件控件名称,注意FileItem下标从1开始
formName=request2.FileItem(intTemp)
'显示源文件路径与文件名
response.write "<br>"&request2.form(formName&"_Path")&request2.form(formName&"_Name")
'显示文件大小(字节数)
response.write "("&request2.form(formName&"_Size")&") => "
'显示目标文件路径与文件名
response.Write formPath&request2.form(formName)&" "
'显示文件保存状态
select case request2.form(formName&"_Err")
case -1:
response.write "没有文件上传<br>"
case 0:
response.write "上传文件成功<br>"
intCount=intCount+1
case 1:
response.write "文件太大,拒绝上传<br>"
case 2:
response.write "文件格式不对,拒绝上传<br>"
case 3:
response.write "文件太大且格式不对,拒绝上传<br>"
end select
upfile=request2.form(formName)
protitle=request2.Form("protitle")
rs.addnew
rs("propic")=upfile
rs("protitle")=protitle
rs.update
next
'----列出所有上传了的文件结束----
rs.close
set rs=nothing
response.write "<br>"&intCount&" 张图片上传成功! "
response.write "[<a href=""javascript:history.back();"">返回</a>]"
%> </td>
</tr>
</table>
</body>
</html>
<%
'释放上传对象
set request2=nothing
%>