设为首页收藏本站

新微赢技术网

 找回密码
 注册
搜索
热搜: 回贴
查看: 111|回复: 5
打印 上一主题 下一主题

如何实现不确定张数图片上传

[复制链接]
跳转到指定楼层
1#
发表于 2010-1-7 02:52:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我要实现一个产品对应多副图片,而且图片张数不固定,提交页面已经做好,处理页面老出问题,望高人指点下
提交页: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)%>;
2#
发表于 2010-1-7 02:52:05 | 只看该作者
for each formName in upload.File
获取表单文件域的值
回复 支持 反对

使用道具 举报

3#
发表于 2010-1-7 02:52:08 | 只看该作者
有人看到吗?
回复 支持 反对

使用道具 举报

4#
发表于 2010-1-7 02:52:11 | 只看该作者
其中image表中相关字段为id pid url 三个
其他字段都在PRO表中,有pid prid等,image中的pid对应pro表中的pid
回复 支持 反对

使用道具 举报

5#
发表于 2010-1-7 02:52:14 | 只看该作者
不行啊,upload.file用在这出错,无效
Microsoft VBScript 运行时错误 (0x800A01C2)
错误的参数个数或无效的参数属性值: 'upload.File'
/17/gxxt/product/adddetailupdate.asp, 第 52 行
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

申请友链|小黑屋|最新主题|手机版|新微赢技术网 ( 苏ICP备08020429号 )  

GMT+8, 2024-11-19 22:37 , Processed in 0.116753 second(s), 8 queries , Gzip On, Memcache On.

Powered by xuexi

© 2001-2013 HaiAn.Com.Cn Inc. 寰耽

快速回复 返回顶部 返回列表