把一个FORM表的 2张图片保存到 数据库的一个表中~
分别的img1和img2~
现在用 无惧无组建上传不知道这个img怎么取值 希望那个大大能具体解释下~代码如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试上传类</title>
<style type="text/css">
<!--
.tr {font-size: 12pt;}
-->
</style>
</head>
<body>
<form action="up.asp" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0" class="tr">
<tr>
<td width="129" height="30" align="right" class="table">用户名:</td>
<td width="271" height="30" align="left" class="table"><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td height="30" align="right" class="table">密码:</td>
<td height="30" align="left" class="table"><input name="pwd" type="password" /></td>
</tr>
<tr>
<td height="30" align="right" class="table">头像:</td>
<td height="30" align="left" class="table"><input name="img" type="file" id="img" /></td>
</tr>
<tr>
<td height="30" align="right" class="table">头像:</td>
<td height="30" align="left" class="table"><input name="img1" type="file" id="img1" /></td>
</tr>
<tr>
<td height="30" align="right"><input name="Submit" type="submit" value="提交" /></td>
<td height="30" align="left"><input name="Submit2" type="reset" value="重置" /></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
</body>
</html>
---------------------------执行页面------------------------------
<!--#include FILE="upfile_class.asp"-->
<%
Dim upfile,formName,FileName,oFile
Set upfile=new upfile_class ''建立上传对象
'upfile.NoAllowExt="asp;exe;htm;html;aspx;cs;vb;js;" '设置上传类型的黑名单
upfile.AllowExt = "jpg;gif;bmp;png" '设置上传类型的白名单
upfile.GetData (10240000) '取得上传数据,限制最大上传10M
Sub CheckSize(Tmp,Str)
If Tmp.FileSize < 10 Then
Response.Write("<script language='javascript'>alert('"&Str&"没有上传图片!');history.go(-1);</script>")
Response.End()
End If
End Sub
Sub CheckExt(Tmp,Str)
'For I = 0 To Ubound(Arr)
If Instr(upfile.AllowExt,Tmp.FileExt) <= 0 Then
Response.Write("<script language='javascript'>alert('"&Str&"上传的图片格式不正确!');history.go(-1);</script>")
Response.End()
End If
'Next
End Sub
If upfile.isErr Then '如果出错
select case upfile.isErr
case 1
Response.Write("<script language='javascript'>alert('你没有上传数据呀???是不是搞错了??');history.go(-1);</script>")
case 2
Response.Write("<script language='javascript'>alert('你上传的文件超出我们的限制,最大10M');history.go(-1);</script>")
case 3
Response.Write("<script language='javascript'>alert(该后缀文件名不允许上传!只能上传以下格式文件:\n"&upfile.AllowExt&"');history.go(-1);</script>")
end select
Else
username = upfile.form("username")
pwd = upfile.form("pwd")
If username = "" Then '判断用户名是否为空
Response.Write("<script language='javascript'>alert('用户名不能为空');history.go(-1);</script>")
Response.End()
End If
Response.Write("用户名:"&username&"<br>密 码:"&pwd&"<br>"&"<br>")
Call CheckSize(upfile.file("img"),"头像一")
Call CheckExt(upfile.file("img"),"头像一")
Call CheckSize(upfile.file("img1"),"头像二")
Call CheckExt(upfile.file("img1"),"头像二")
'Response.Write("<br>"&upfile.file("img").FileSize&"<br>"&upfile.file("img1").FileSize)
For Each formname In upfile.file
Set oFile = upfile.file(formname)
fileName=upfile.AutoSave(formname,server.MapPath("upload")&("\")) '保存文件,按照当前时间命名, 保存相对路径时需要单独加"/"或"\"
If upfile.isErr Then
Response.Write("<script language='javascript'>alert('"&upfile.errmessage&"');history.go(-1);</script>")
Response.End()
End If
Response.Write("上传前的路径:"&oFile.FilePath&"<br>大小:"&oFile.FileSize&"<br>文件名:"&oFile.FileName&"<br>")
Response.Write("上传后的路径:"&server.MapPath("upload")&"\"&"<br>文件名:"&fileName&"<p>")
Set oFile = Nothing
Next
Set upfile = Nothing
End If
%>
-------------
怎么能分别取到img 和 img1的值呢?