怎样用asp实现多张图片同时上传并读取????
我的上传界面是:
<html>
<head>
<title>普通多文件上传 </title>
</head>
<body>
<form method="post" action="uptodir.asp" enctype="multipart/form-data">
<p>上传图片一:<input type="file" name="File1"></p>
<p>上传图片二:<input type="file" name="File2"></p>
<p>上传图片三:<input type="file" name="File3"></p>
<input type="submit" value="上传">
</form>
</body>
</html>
我的处理界面是:uptodir.asp
<!-- #include file="Upload.asp" -->
<!-- #include file="conn.asp" -->
<%
Server.ScriptTimeout =20*60 '上传超时时间20分钟
dim userfilepath,userfilepath1,userfilepath2
formPath = "UploadFiles/"
Set upload= New DoteyUpload
Upload.SaveTo(formPath) '将文件根据其文件名统一保存在某路径下
If upload.ErrMsg = "" then
Response.Write ("form传递来的数据:<BR>")
For each formName in upload.Form ''列出所有form数据
Response.write formName & "=" & upload.Form(formName) & "<br>"
temp=temp & "||" & upload.Form(formName) '用字符串存表单所有变量
next
temp2=split(temp,"||") '将字符串拆开存入数组
userfilepath=temp2(1) '取出数组元素
userfilepath1=temp2(2)
userfilepath2=temp2(3)
Response.Write ("<BR><BR>已经成功上传文件:<BR>")
For Each formName In upload.Files ''列出所有上传了的文件
Set file = upload.Files(formName) ''生成一个文件对象
Set file1 = upload.Files(formName) ''生成一个文件对象
Set file2 = upload.Files(formName) ''生成一个文件对象
userfilepath=formPath & File.FileName
userfilepath1=formPath & File1.FileName
userfilepath2=formPath & File2.FileName
response.write "<a target=_blank href='" & formPath & File.FileName & "'>" & formPath & File.FileName & "下载此文件" & "</a> 成功!<br>"
response.write "<br /><BR>"
Set file=nothing
Next
Else
Response.Write("上传过程中出现错误:<br>" & Upload.ErrMsg)
End If
Set upload=nothing
response.write "<hr>"
response.write "文件保存路径:" & userfilepath
response.write "文件保存路径:" & userfilepath1
response.write "文件保存路径:" & userfilepath2
'开始写入数据库
set rs=server.createobject("adodb.recordset")
SQL="select * from uploadfiles where id is null"
rs.open SQL,conn,1,3
rs.addnew
rs("userfilepath")=userfilepath
rs("userfilepath1")=userfilepath1
rs("userfilepath2")=userfilepath2
rs.Update
rsclose()
connclose()
response.write "<br><br><br>写入数据库完毕!"
%>
<BR><A HREF="showuserfiles.asp">查看所有用户上传记录</A>
为什么我存入三个的路径到数据库中的时候,最后一张的路径会覆盖前面二个的路径?????
<html>
<head>
<title>普通多文件上传 </title>
</head>
<body>
<form method="post" action="uptodir.asp" enctype="multipart/form-data">
<p>上传图片一:<input type="file" name="File1"></p>
<p>上传图片二:<input type="file" name="File2"></p>
<p>上传图片三:<input type="file" name="File3"></p>
<input type="submit" value="上传">
</form>
</body>
</html>
我的处理界面是:uptodir.asp
<!-- #include file="Upload.asp" -->
<!-- #include file="conn.asp" -->
<%
Server.ScriptTimeout =20*60 '上传超时时间20分钟
dim userfilepath,userfilepath1,userfilepath2
formPath = "UploadFiles/"
Set upload= New DoteyUpload
Upload.SaveTo(formPath) '将文件根据其文件名统一保存在某路径下
If upload.ErrMsg = "" then
Response.Write ("form传递来的数据:<BR>")
For each formName in upload.Form ''列出所有form数据
Response.write formName & "=" & upload.Form(formName) & "<br>"
temp=temp & "||" & upload.Form(formName) '用字符串存表单所有变量
next
temp2=split(temp,"||") '将字符串拆开存入数组
userfilepath=temp2(1) '取出数组元素
userfilepath1=temp2(2)
userfilepath2=temp2(3)
Response.Write ("<BR><BR>已经成功上传文件:<BR>")
For Each formName In upload.Files ''列出所有上传了的文件
Set file = upload.Files(formName) ''生成一个文件对象
Set file1 = upload.Files(formName) ''生成一个文件对象
Set file2 = upload.Files(formName) ''生成一个文件对象
userfilepath=formPath & File.FileName
userfilepath1=formPath & File1.FileName
userfilepath2=formPath & File2.FileName
response.write "<a target=_blank href='" & formPath & File.FileName & "'>" & formPath & File.FileName & "下载此文件" & "</a> 成功!<br>"
response.write "<br /><BR>"
Set file=nothing
Next
Else
Response.Write("上传过程中出现错误:<br>" & Upload.ErrMsg)
End If
Set upload=nothing
response.write "<hr>"
response.write "文件保存路径:" & userfilepath
response.write "文件保存路径:" & userfilepath1
response.write "文件保存路径:" & userfilepath2
'开始写入数据库
set rs=server.createobject("adodb.recordset")
SQL="select * from uploadfiles where id is null"
rs.open SQL,conn,1,3
rs.addnew
rs("userfilepath")=userfilepath
rs("userfilepath1")=userfilepath1
rs("userfilepath2")=userfilepath2
rs.Update
rsclose()
connclose()
response.write "<br><br><br>写入数据库完毕!"
%>
<BR><A HREF="showuserfiles.asp">查看所有用户上传记录</A>
为什么我存入三个的路径到数据库中的时候,最后一张的路径会覆盖前面二个的路径?????
...全文
相关推荐
asp.net实现上传图片后并显示
1.实现上传图片功能 2.上传图片后将图片显示出来 3.获取上传后图片信息
实现ASP批量图片上传与预览
在信息技术高速发展的今天,ASP批量图片上传技术作为网站后台管理的一个重要功能,其重要性不言而喻。该技术允许用户一次性上传多张图片,大大提高了图片管理的效率和便捷性。本章旨在为读者提供一个全面的视角,全面介绍ASP批量图片上传技术。HTML5是第五代超文本标记语言,它的出现标志着Web技术的一个重大进步。HTML5引入了许多新的API和元素,极大地增强了Web应用的能力。
Flash至ASP图片上传功能的完整实现
Flash曾经是开发动态网页和富客户端应用的主流技术之一。通过ActionScript编程,Flash能够与用户进行交互,并执行文件上传等复杂操作。尽管现在HTML5等新技术已经逐渐取代Flash,但在某些遗留系统中,Flash图片上传仍具有其实用价值。
asp.net 选择多张图片批量上传
使用visual studio2017打开,可以选择多张图片进行上传,在选择提交前,可以将选择的图片在页面上展现出来,现在能够将其进行统一保存到指定的路径,如果想将其添加到数据库,自己将其保存下来的路径添加到数据库即可
asp.net上传多张图片
asp.net上传多张图片,点一下按钮增加一个上传图片控件



