关于asp多个文件上传的有关问题
关于asp多个文件上传的问题
界面:

数据库:

想要实现上图这种功能,每一行是循环出来的,现在只有第一行点击上传后文件名能显示在后面的文本框中点击确定能成功传至数据库的第一行,
剩下三行,每次点击上传后文件名都还是添加到了第一行,怎么能让点击哪行的上传按钮就传到哪行呢?
我也不知道怎么描述了,下面是代码:
三个文件:1、function3.asp;2、file.asp;3、upload.asp
1、function3.asp
2、file.asp
3、upload.asp
------解决思路----------------------
k.document.getElementById("document").value = url;
这里id改成动态值
界面:
数据库:
想要实现上图这种功能,每一行是循环出来的,现在只有第一行点击上传后文件名能显示在后面的文本框中点击确定能成功传至数据库的第一行,
剩下三行,每次点击上传后文件名都还是添加到了第一行,怎么能让点击哪行的上传按钮就传到哪行呢?
我也不知道怎么描述了,下面是代码:
三个文件:1、function3.asp;2、file.asp;3、upload.asp
1、function3.asp
<!--#include file="../include/chkadmin.asp"-->
<!--#include file="../include/conn.asp"-->
<!--#include FILE="../include/upload_5xsoft.inc"-->
<html>
<script type="text/javascript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function MM_setTextOfTextfield(objId,x,newText) { //v9.0
with (document){ if (getElementById){
var obj = getElementById(objId);} if (obj) obj.value = newText;
}
}
//-->
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE type="text/css">
body { font-size: 9pt; font-family: 宋体, Arial;color: #000000}
.STYLE1 {font-size: 12px}
</STYLE>
</head>
<body>
<%
dim action
action=request.QueryString("action")
Const MaxPerPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
%>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from [function] ",conn,1,1
%>
<table width=900 border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#C0C0C0" id="table1" style="border-collapse: collapse; margin-top:0px;" class="STYLE1">
<tr align="center">
<th width="224" bgcolor="dbe7f3" class="STYLE1">项目类型</th>
<th width="123" height="30" bgcolor="dbe7f3" class="STYLE1">
<p align="center"><font color="#000000">子项</font></th>
<th width="106" bgcolor="dbe7f3" >操作指南</th>
<th colspan="2" bgcolor="dbe7f3" >上传确定</th>
</tr>
<% if err.number<>0 then
response.write("<script language=JavaScript>alert('不能为空!');document.location='function2.asp';</script>")
Response.End
end if
if rs.eof And rs.bof then
Response.Write "<p align='center'>没有记录!</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,""&request.ServerVariables("script_name")&""
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
showContent
showpage totalput,MaxPerPage,""&request.ServerVariables("script_name")&""
else
currentPage=1
showContent
showpage totalput,MaxPerPage,""&request.ServerVariables("script_name")&""
end if
end if
end if
'=============分页类代码结束%>
<%'=============循环体开始
sub showContent
dim i
i=0
do while not rs.eof%>
<form action="function3.asp" method="post" name="form1" id="form1">
<input name="id" type="hidden" value="<%=rs("id")%>" id="id">
<tr>
<td align="center" height="30"><div align="center"><%=rs("item_class")%></div></td>
<td><div align="center"><%=rs("item_name")%></div></td>
<td align="center">
<script language=javascript>
function openDialogWin()
{
var result = window.showModalDialog("file.asp",window,"dialogHeight:200px; dialogWidth:300px; status:no; help:no; scroll:no ");
}
</script>
<input name="button" type="button" id="button" onClick="openDialogWin()" value="上传" >
</td>
<td width="220" align="center" style="border-right:0">
<input type="text" name="document" id="document">
</td>
<td width="185" style="border-left:0">
<input type="submit" name="Submit" value="提交">
</td>
</tr>
</form>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close '释放资源
set rs=nothing
End Sub
'=============循环体结束%>
<%'=============放置分页显示开始
Function showpage(totalnumber,maxperpage,filename)
Dim n
If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If %> <%End Function
'=============放置分页显示结束%>
</table>
<%
if request("id")<>0 then
set rs1=server.createobject("adodb.recordset")
rs1.open "select * from function where id="&Request("id"),conn,1,3
rs1("guide")=Request("document")
rs1.Update
rs1.Close
Set rs1=nothing
end if
%>
</body>
</html>
2、file.asp
<HTML>
<HEAD>
<TITLE>文件上传</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body, a, table, div, span, td, th, input, select{font:9pt;font-family: "宋体", Verdana, Arial, Helvetica, sans-serif;}
body {padding:5px}
</style>
<script language="JavaScript">
// 点确定时执行
function ok(){
// 上传文件判断
if (d_file.form1.file.value=="") return false;
GetFileName(d_file.form1.file.value, "\\");
// 显示正在上传文件
divProcessing.style.display="";
// 上传表单提交
d_file.form1.submit();
}
// 取文件名到隐藏的输入框
function GetFileName(url, opt){
filename.value=url.substr(url.lastIndexOf(opt)+1);
}
// 文件上传完成时执行,带入上传文件名
function UploadSaved(sPathFileName){
filename.value = sPathFileName;
var url = filename.value;
var k=window.dialogArguments;
k.document.getElementById("document").value = url;
window.returnValue = null;
window.close();
}
</script>
<BODY bgColor=#006699>
<p><br>
</p>
<table border=0 cellpadding=0 cellspacing=0 align=center height="98" width="304">
<tr>
<td width="304" align="center" height="82" bgcolor="#FFFFFF">
<br>
<br>
<fieldset style="width: 280; height: 39">
<legend>文件来源</legend>
<Script Language=JavaScript>
document.write('<iframe id=d_file frameborder=0 src="upload.asp?action=file" align="middle" width="100%" height="40" scrolling=no></iframe>');
</Script>
</fieldset><br>
</td></tr>
<tr><td align=right height="46" bgcolor="#FFFFFF">
<p align="center"><input type=submit value=' 确定 ' id=Ok onClick="ok()"> <input type=button value=' 取消 ' onClick="window.close();"><input type=hidden id=filename value=""><br>
</td></tr>
</table>
<div id=divProcessing style="width:255px;height:46px;position:absolute;left:87px;top:74px;display:none">
<table border=0 cellpadding=0 cellspacing=1 bgcolor="#FFFFFF" width="100%" height="100%"><tr>
<td bgcolor=#FFFFFF><marquee align="middle" behavior="alternate" scrollamount="5"><font color=#FFFFFF>...文件上传中...请等待...</font></marquee></td></tr></table>
</div>
</body>
</html>
3、upload.asp
<!--#include file="../include/conn.asp"-->
<!--#include FILE="../include/upload_5xsoft.inc"-->
<HTML>
<HEAD>
<TITLE>文件上传</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body, a, table, div, span, td, th, input, select{font:9pt;font-family: "宋体", Verdana, Arial, Helvetica, sans-serif;}
body {padding:0px;margin:0px}
</style>
</head>
<body bgcolor=#006699>
<%
Dim sAction
sAction = Trim(Request.QueryString("action"))
if sAction ="up" then
set upload=new upload_5xsoft
set file=upload.file("file")
filename="../unit/up/"&Session("name")&year(date())&month(date())&day(date())&hour(now())&minute(now())&second(now())&".rar"
if file.fileSize>0 then
file.saveAs Server.mappath(filename)
//Session("filename")=filename
end if
set file=nothing
set upload=nothing
Call OutScript("parent.UploadSaved('" & filename & "')")
elseif sAction ="file" then
%>
<div align="center">
<table width="78%" border="0" cellspacing="0" cellpadding="0" bgcolor="#99CCFF">
<tr>
<td height="60" align="center" valign="bottom"><form action="Upload.asp?action=up" method="post" enctype="multipart/form-data" name="form1">
<p align="left"> <input type="file" name="file" id="file">
</p>
</form></td>
</tr>
</table>
<p align="left"><br>
<br>
</div>
<%
end if
Sub OutScript(str)
Response.Write "<script language=javascript>" & str & ";history.back()</script>"
End Sub
%>
</body>
</HTML>
------解决思路----------------------
k.document.getElementById("document").value = url;
这里id改成动态值