我要实现一个产品对应多副图片,而且图片张数不固定,提交页面已经做好,处理页面老出问题,望高人指点下
提交页:test.asp
<!--#include FILE="upload_5xsoft.inc"-->
<%
set upload=new upload_5xSoft ''建立上传对象
num=upload.form("num")
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加産品問題</title>
<style type="text/css">
<!--
.STYLE2 {
color: #0000FF;
font-size: 24px;
}
-->
</style>
</head>
<script LANGUAGE="javascript">
<!--
function FrmAddLink_onsubmit() {
var i, n;
//Function to open pop up window
function openWin(theURL,winName,features) {
window.open(theURL,winName,features);
}
}
//-->
</script>
<script>
function check()
{
document.FrmAddLink.action="test.asp";
document.FrmAddLink.submit();
}
</script>
<table width="971">
<form action="adddetailupdate.asp?pid=<%=upload.form("ptypename")%>&prid=<%=upload.form("prid")%>&iid=<%=upload.form("num")%>" method="post" enctype="multipart/form-data" name="FrmAddLink" LANGUAGE="javascript"
onsubmit="return FrmAddLink_onsubmit()" >
<table width="683" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#666666" bgcolor="#33CCFF">
<tr>
<td colspan="2" align="center"><span class="STYLE2">数据添加</span></td>
</tr>
<tr>
<td width="74" align="center">number:</td>
<td width="609"><input name="pnumber" type="text" id="pnumber" size="66" /></td>
</tr>
<tr>
<td align="center">pfmc :</td>
<td><input name="pfmc"size="66"/></td>
</tr>
<tr>
<td align="center">prid:</td>
<td><select size="1" name="prid" style="font-family: 宋体; font-size: 9pt" >
<option selected value="">请选择种类</option>
<option value="1">sunvisor</option>
<option value="2">dvd player</option>
<option value="3">in-dash monitor</option>
<option value="4">flip down monitor</option>
<option value="5">headrest</option>
<option value="6">standalone</option>
</select></td>
</tr>
<tr>
<td align="center">typename:</td>
<td><select size="1" name="ptypename" style="font-family: 宋体; font-size: 9pt" >
<option selected value="">请选择种类</option>
<option value="sunvisor1">sunvisor1</option>
<option value="sunvisor2">sunvisor2</option>
<option value="sunvisor3">sunvisor3</option>
<option value="sunvisor4">sunvisor4</option>
<option value="dvd player1">dvd player1</option>
<option value="dvd player2">dvd player2</option>
<option value="dvd player3">dvd player3</option>
<option value="dvd player4">dvd player4</option>
<option value="in-dash monitor1">in-dash monitor1</option>
<option value="in-dash monitor2">in-dash monitor2</option>
<option value="in-dash monitor3">in-dash monitor3</option>
<option value="in-dash monitor4">in-dash monitor4</option>
<option value="flip down monitor1">flip down monitor1</option>
<option value="flip down monitor2">flip down monitor2</option>
<option value="flip down monitor3">flip down monitor3</option>
<option value="flip down monitor4">flip down monitor4</option>
<option value="headrest1">headrest1</option>
<option value="headrest2">headrest2</option>
<option value="headrest3">headrest3</option>
<option value="headrest4">headrest4</option>
<option value="standalone1">standalone1</option>
<option value="standalone2">standalone2</option>
<option value="standalone3">standalone3</option>
<option value="standalone4">standalone4</option>
</select></td>
</tr>
<tr>
<td width="74" align="right">
<p align="center">color:</td>
<td align="left"><p >
<input name="color" size="66">
</td>
</tr>
<tr>
<td width="74" align="right">
<p align="center">fulname:</td>
<td align="left"><p>
<input name="fulname" size="66">
</td>
</tr>
<tr>
<td width="74" align="right">
<p align="center">products:</td>
<td align="left"><p>
<input name="products" size="66">
</td>
</tr>
<tr>
<td width="74" height="20" align="right">
<div align="center"><span
class="smallFont">ppic:</span></div> </td>
<td width="609" height="20" valign="middle"><iframe name="ad2" frameborder=0 width=235 height=20 scrolling=no src=uploadface2.asp></iframe>
<input id="ppic" name="ppic" size="30" class="smallInput" maxlength="100" style="font-family: 宋体; font-size: 9pt" ></td>
</tr>
<tr>
<td width="74" height="20" align="right">
<div align="center"><span
class="smallFont">photo:</span></div>; </td>
<td width="609" height="20" valign="middle">
<iframe name="ad" frameborder=0 width=235 height=20 scrolling=no src=uploadface.asp></iframe>
<input id="photo" name="photo" size="30" class="smallInput" maxlength="100" style="font-family: 宋体; font-size: 9pt" ></td>
</tr>
<tr>
<td align="center">photo1:</td>
<td><table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="300" >
<tr>
<td width="965">
<p>
<input name="num" type="text" id="num" />
<input type="button" name="Submit" value="按钮" onClick="check()"/>
<br />
<%
'num=request("num")
if num="" then
num=10
end if
for i=1 to num
%>
<input name="file_<%=i%>" type="file" id="file_<%=i%>" />
<%
next
%>
<input name="hiddenField" type="hidden" value="<%=num%>" />
<br />
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"> </td>
<td> </td>
</tr>
<tr>
<td>functions</td>
<td><textarea name="pfunction" cols="40" rows="8" id="pfunction"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="提交" /></td>
<input name="id" type="hidden" id="pid" value="<%=upload.Form("pid")%>" />
<input name="id1" type="hidden" id="prid" value="<%=upload.Form("prid")%>" />
</tr>
</table>
<input name="total" type="hidden" id="total" value="<%=num%>" />
</form> </table>
</body>
</html>
处理页adddetailupdate.asp
<!--#include file="upload_5xsoft.inc"-->
<!--#include file="conn.asp"-->
<%set rs = server.createobject("adodb.recordset")
sql = "select top 1 * From pro order by pid desc"
rs.open sql,conn,1,3
pid = rs("pid") + 1 %>
<%
response.Charset="utf-8"
session.CodePage=65001
set upload=new upload_5xsoft
pnumber=upload.form("pnumber")
pfmc=upload.form("pfmc")
ptypename=upload.form("ptypename")
ppic=upload.form("ppic")
prid=upload.form("prid")
color=upload.form("color")
fulname=upload.form("fulname")
photo=upload.form("photo")
photo1=upload.form("photo1")
photo2=upload.form("photo2")
photo3=upload.form("photo3")
products=upload.form("products")
compatible=upload.form("compatible")
applicable1=upload.form("applicable1")
applicable2=upload.form("applicable2")
applicable3=upload.form("applicable3")
accessory=upload.form("accessory")
pfunction=upload.form("pfunction")
set ars=server.CreateObject("adodb.recordset")
sql="select top 1 * from pro"
ars.open sql,conn,3,2
ars.addnew
ars("pnumber")=pnumber
ars("pfmc")=pfmc
ars("ptypename")=ptypename
ars("ppic")=ppic
ars("color")=color
ars("fulname")=fulname
ars("photo")=photo
ars("products")=products
ars("compatible")=compatible
ars("pfunction")=pfunction
ars("prid")=prid
num=upload.form("total")
ars.update
ars.close()
'set ars=nothing
set ars=nothing
for n=1 to num
set file=upload.file("file"&n)
if file.fileSize>0 then
Fname=file.FileName
set rs=server.createobject("adodb.recordset")
sql="select top 1 * from [image] order by id desc"
rs.open sql,conn,3,2
rs.addnew
rs("pid")=pid
rs("url")="d"&rs("pid")&Fname
rs.update
sid=rs("pid")
rs.close()
set rs=nothing
file.saveAs Server.mappath("image/d"&sid&Fname)
end if
set file=nothing
next
set upload=nothing
conn.close()
set conn=nothing
'for i=11 to 20
' set file=upload.file("file"&i)
' if file.fileSize>0 then
' Fname=file.FileName
' set rs=server.createobject("adodb.recordset")
' sql="select top 1 * from [image1]"
' rs.open sql,conn,3,2
' rs.addnew
' rs("pid")=pid
' rs("url")="d"&rs("pid")&Fname
' response.Write(pid)
' rs.update
' sid=rs("pid")
' rs.close()
' set rs=nothing
' file.saveAs Server.mappath("image/d"&sid&Fname)
' end if
' set file=nothing
'next
'set upload=nothing
'conn.close()
'set conn=nothing
%>
<%response.Write (pid) %>;
<%response.Write (num) %>;
<%response.Write (prid)%>;
<%response.write (Fname)%>;
[此贴子已经被阳光白雪于2007-4-18 18:24:18编辑过]