| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 515 人关注过本帖
标题:如何实现不确定张数图片上传
只看楼主 加入收藏
solon
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-4-18
收藏
 问题点数:0 回复次数:4 
如何实现不确定张数图片上传

我要实现一个产品对应多副图片,而且图片张数不固定,提交页面已经做好,处理页面老出问题,望高人指点下
提交页: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编辑过]

搜索更多相关主题的帖子: html 图片 blank content include 
2007-04-18 18:20
solon
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-4-18
收藏
得分:0 
有人看到吗?
2007-04-18 18:23
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 

for each formName in upload.File
获取表单文件域的值


专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-04-18 18:31
solon
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-4-18
收藏
得分:0 
其中image表中相关字段为id pid url 三个
其他字段都在PRO表中,有pid prid等,image中的pid对应pro表中的pid
2007-04-18 18:31
solon
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-4-18
收藏
得分:0 
不行啊,upload.file用在这出错,无效
Microsoft VBScript 运行时错误 (0x800A01C2)
错误的参数个数或无效的参数属性值: 'upload.File'
/17/gxxt/product/adddetailupdate.asp, 第 52 行
2007-04-18 18:33
快速回复:如何实现不确定张数图片上传
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022219 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved