日期:2014-05-16 浏览次数:20785 次
... ...
For Each formName In upload.Files ''列出所有上传了的文件
Set file = upload.Files(formName) ''生成一个文件对象
'-------------------下面写入数据库-------------------------------------------------
Sql = "insert into p_table (id,productname,image1) values"
Sql = Sql& " ('"& upload.Form("product_id") &"','"& upload.Form("product_name") &"','"& File.NewFileName &"')"
conn.execute(sql)
Set file=nothing
Next
... ...
'前面的其它代码不改
If upload.ErrMsg = "" then
arr = Array("", "", "", "", "") '添加代码,数组1:新文件名
oldname = Array("", "", "", "", "") '添加代码,数组2:旧文件名
i = 0 '给数组赋初始值
For Each formName In upload.Files ''列出所有上传了的文件
Set file = upload.Files(formName) ''生成一个文件对象
arr(i) = formPath&File.NewFileName ' 构建数组1,用于存储更名后的文件名和路径
oldname(i) = File.FileName'构建数组2,用于存放第一个页面上传时给出的文件原始名称
i = i +1 '开始循环计数
Set file=nothing '释放对象
Next
''以下q和s分别用于sql语句向DB插入数据
q = ""
s = ""
For i = 0 To UBound(arr)
If arr(i) = "" Then
s = s & "Null,"
Else
s = s &