| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 730 人关注过本帖
标题:关于一传多个图片,同时将数据保存问题?
只看楼主 加入收藏
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
 问题点数:0 回复次数:9 
关于一传多个图片,同时将数据保存问题?
我用的是化境无组上传:
<script language="javascript">
function setid()
{
str='<br>';
Name='<br>';
if(!window.PhotoAdd.UserName.value)
window.PhotoAdd.UserName.value=1;
for(i=1;i<=window.PhotoAdd.UserName.value;i++)
{
str+='文件'+i+':<input type="file" name="file'+i+'" style="width:200" class="INput"><br><br>';
Name+='名称'+i+':<input name="PhotoName'+i+'" type="text" class="INput"><br><br>';
}
window.upid.innerHTML=str+'<br>';
window.upname.innerHTML=Name+'<br>';
}
</script>
这是动态,得到上传文件域和文本框。
我以有下3个问题:
1:如何在接收页知道。。有多少个文本框。。。
2:我们应该如何把这些数保存在数据库(不是保存图片,是保存他的路径和名字),
是在上传文件那页保存:
for each formName in PhotoUpLoad.objForm ''列出所有form数据
'response.write formName&"="&PhotoUpLoad.form(formName)&"<br>"
Response.Write formName
next
这是得到所有表单数据。但我们要怎么把他分开来

3:还是我们应该另外在一页读入数据库?


谢谢帮忙!!
搜索更多相关主题的帖子: 一传 数据 window UserName 
2006-01-15 19:08
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
收藏
得分:0 
化境有同等于resquest的方法吗?

2006-01-15 19:19
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
有的
PhotoUpLoad.form()
如何知道我们设定多少个.
我们应该...同片上传成功同时更入数据库吧?

中国人的财富网:http://www..cn/
2006-01-15 19:23
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
收藏
得分:0 
i=0
for each formName in upload.file
i=i+1
next

我也想想

2006-01-15 19:34
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
谢谢了,现在只差存入数据库了.
iCount=1
response.write "<br>"
for each formName in PhotoUpLoad.objFile ''列出所有上传了的文件
set file=PhotoUpLoad.file(formName) ''生成一个文件对象
ranNum=int(90000*rnd)+10000
PhotoName1=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
rs("PhotoName")=PhotoUpLoad.form("PhotoName"&iCount) '这是另取的名字
rs("PhotoName1")=PhotoName1 '这是用时间生成,照片真正的名字
rs("PhotoPath")=PhotoUpLoad.form("PhotoPath")
rs.update
file.SaveAs Server.mappath(PhotoPath&PhotoName1)''保存文件
iCount=iCount+1
Next
不知道行不行?
如果上传不成功了.那数据还是保存在数据库里了.

中国人的财富网:http://www..cn/
2006-01-15 19:45
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
收藏
得分:0 
不用谢,我向你学习才对。
你那样应该可以吧,或者你可以先上传文件,再保存数据嘛。如果上传时没有错误就保存数据

2006-01-15 19:54
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
如何判断能有没有上传成功!!!
好像就算没上传成功,他也会执行下面的语句!

中国人的财富网:http://www..cn/
2006-01-15 19:57
dreame
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:521
专家分:0
注 册:2005-10-23
收藏
得分:0 

楼主是不是可以这样:
1.文本框可以通过i来获取,楼上已经说过!

2.保存数据:
For i=1 to total //total为i的总数;
  file=PhotoUpLoad.form("file"&i)
PhotoName=PhotoUpLoad.form("PhotoName"&i)
strSql=""
next


有时候真的想放弃寂寞的等待,但她是那么的可爱!I love u forever!
2006-01-15 20:09
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
收藏
得分:0 

if err then
这样行不?


2006-01-15 20:16
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
if err then 不知道行不行..让他出错,好像有点难...





谢谢了!!
成功了..总的代码如下: 还有很多条件.我自已在加一下..

<%
Sub AddPhoto()
dim PhotoUpLoad,file,formName,PhotoPath,iCount
Set PhotoUpLoad=new upload_5xsoft '建立上传对象
PhotoPath=PhotoUpLoad.form("PhotoPath")
''''''得到上传保存路径'''''''''''''
If PhotoPath="individual" Then
PhotoPath1="../ClassPhoto/individual/"
ElseIf PhotoPath="collectivity" Then
PhotoPath1="../ClassPhoto/collectivity/"
End If
Set rs=Server.CreateObject("Adodb.RecordSet")
Sql="Select * from Photo"
rs.open Sql,conn,1,3
for each formName in PhotoUpLoad.objForm ''列出所有form数据
'response.write formName&"="&PhotoUpLoad.form(formName)&"<br>"

next
iCount=1
response.write "<br>"
for each formName in PhotoUpLoad.objFile ''列出所有上传了的文件
set file=PhotoUpLoad.file(formName) ''生成一个文件对象
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
fileExt=lcase(right(file.filename,3))
ranNum=int(90000*rnd)+10000
PhotoName1=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
file.SaveAs Server.mappath(PhotoPath&PhotoName1)''保存文件
rs.addnew
rs("PhotoName")=PhotoUpLoad.form("PhotoName"&iCount) '这是另取的名字
rs("PhotoAutor")=PhotoUpLoad.form("PhotoAutor")
rs("PhotoUrl")=PhotoPath1&PhotoName1 '这是用时间生成,照片真正的路径
rs("TypeName")=PhotoPath
rs("PhotoContent")=PhotoUpLoad.form("PhotoContent")
rs.update
Response.Write "来自" &file.FilePath& "<font color='blue'>" &file.FileName& "</font>(" &file.FileSize& "KB)"
Response.write "=>保存为" &PhotoPathPath& "<font color='red'>" &PhotoName1& "</font>上传成功!<br>"
iCount=iCount+1
end if
set file=nothing
next
rs.close
Set rs=nothing
Call CloseConn()
set upload=nothing ''删除此对象
End Sub
%>

中国人的财富网:http://www..cn/
2006-01-15 20:33
快速回复:关于一传多个图片,同时将数据保存问题?
数据加载中...
 
   



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

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