多文件上传

fuzijing 2008-12-09 04:36:46
上传文件实现多选
可以获取文件信息入库

实在没时间了,本人水平一般,希望源码,!

谢谢了!
...全文
192 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
zorou_fatal 2008-12-10
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 fuzijing 的回复:]
我汗 slickupload 的demo使用了

它也是不能多选的.....


[/Quote]

仔细看demo,里面有multiple上传的。
zjybushiren88888 2008-12-10
  • 打赏
  • 举报
回复
http://www.cnblogs.com/cloudgamer/archive/2008/10/20/1314766.html
肯定有楼主需要的
jiang_jiajia10 2008-12-10
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 oec2003 的回复:]
http://www.cnblogs.com/cloudgamer/archive/2008/10/20/1314766.html
[/Quote]
这个就很好啊
zzxxml 2008-12-10
  • 打赏
  • 举报
回复
UP
Riverwcj 2008-12-10
  • 打赏
  • 举报
回复
好像fileupload这个控件可以吧,,,
fuzijing 2008-12-10
  • 打赏
  • 举报
回复
加100
dongb83 2008-12-10
  • 打赏
  • 举报
回复
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

namespace WebApplication1
{
public partial class uploadDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnUpload_Click(object sender, EventArgs e)
{
HttpFileCollection fileToUpload = Request.Files;
foreach (string keyName in fileToUpload.AllKeys)
{
HttpPostedFile file = fileToUpload[keyName];
if (file.FileName == string.Empty)
return;
try
{
string path = Server.MapPath("Images") + @"\" + Path.GetFileName(file.FileName);
using (FileStream writer = new FileStream(path, FileMode.Create, FileAccess.Write))
{
int bufferSize = 4096 * 10;
byte[] buffer = new byte[bufferSize];
int len = 1;
while (len != 0)
{
len = file.InputStream.Read(buffer, 0, bufferSize);
writer.Write(buffer, 0, len);
}
}
}
catch
{
throw new Exception();
}
}
}
}
}
=========================================================================================
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="uploadDemo.aspx.cs" Inherits="WebApplication1.uploadDemo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Upload Page</title>

<script type="text/javascript">
function $(id)
{
return document.getElementById(id);
}

function stripPath(name)
{
var pieces = name.split("\\");
return pieces[pieces.length-1];
}

function uploadfileOperator(n)
{
var currentFile = $('file' + n);
var newFile = document.createElement('input');
newFile.id = 'file' + (n + 1);
newFile.name = 'file' + (n + 1);
newFile.type = 'file';
newFile.size = currentFile.size;
newFile.onchange = function(){uploadfileOperator(n + 1);}

var newItem = document.createElement('option');
newItem.value = stripPath(currentFile.value);
newItem.id = 'item' + n;
newItem.name = 'item' + n;
newItem.appendChild(document.createTextNode(currentFile.value));
$('sellist').appendChild(newItem);

currentFile.style.display = 'none';
$('fileFolder').appendChild(newFile);
}
</script>

</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<div id="dvupload">
<span id="fileFolder">
<input type="file" onchange="uploadfileOperator(0)" id="file0" name="file0" />
</span>
</div>
<div id="dvlist">
<select id="sellist" style="width:100px" size="6">
</select>
</div>
<div>
<asp:Button ID="btnUpload" Text="UpLoad" runat="server" onclick="btnUpload_Click" />
</div>
</form>
</body>
</html>
=========================================================
microsoft function
takako_mu 2008-12-10
  • 打赏
  • 举报
回复

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpLoad.aspx.cs" Inherits="UpLoad" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html>
<head>
<title>多文件上传</title>
<script type="text/javascript" language="javascript">
function addFile()
{
var str = '<INPUT type="file" size="50" NAME="File" ></br>' ;
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str);
}

function forReset()
{
var files=document.getElementsByName("File");
for(var j=0; j<files.length; j++)
{
files[j].outerHTML=files[j].outerHTML.replace(/value=\w/g,'');
}
}
</script>
</head>
<body>
<form id="form1" method="post" runat="server" enctype="multipart/form-data">
<div align="center">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<p>
<asp:TextBox runat="server" ID="txtName"></asp:TextBox>
</p>
<p>
<asp:DropDownList ID="ddlAction" runat="server" AutoPostBack="true"
onselectedindexchanged="ddlAction_SelectedIndexChanged" >
<asp:ListItem Value="true"></asp:ListItem>
<asp:ListItem Value="false"></asp:ListItem></asp:DropDownList>
</p>
<p>
<asp:RadioButton ID="radYes" runat="server" GroupName="groupName1"/>
<asp:RadioButton ID="radNo" runat="server" GroupName="groupName1"/>
</p>
</div>
<div>

<p id="MyFile"><input type="file" size="50" name="File" /><br/></p>
<p>
<input type="button" value="增加(Add)" onclick="addFile()"/>
<input onclick="forReset()" type="button" value="重置(ReSet)"/>
<asp:Button Runat="server" Text="开始上传" ID="UploadButton"></asp:Button>
</p>
<p>
<asp:Label id="strStatus" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt"
Width="500px" BorderStyle="None" BorderColor="White"></asp:Label>
</p>
<p>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</p>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UploadButton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>



using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;

public partial class UpLoad : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
{
radNo.Checked = true;
this.SaveImages();
ddlAction_SelectedIndexChanged(sender, e);
}
}

private Boolean SaveImages()
{
///'遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files;

/// '状态信息
System.Text.StringBuilder strMsg = new System.Text.StringBuilder();
strMsg.Append("上传的文件分别是:<hr color=red>");
try
{
for (int iFile = 0; iFile < files.Count; iFile++)
{
///'检查文件扩展名字
HttpPostedFile postedFile = files[iFile];
string fileName, fileExtension;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
fileExtension = System.IO.Path.GetExtension(fileName);
strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString() + "<br>");
strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>");
strMsg.Append("上传文件的文件名:" + fileName + "<br>");
strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>");
///'可根据扩展名字的不同保存到不同的文件夹
///注意:可能要修改你的文件夹的匿名写入权限。
postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("images/") + fileName);
}
}
strStatus.Text = strMsg.ToString();
return true;
}
catch (System.Exception Ex)
{
strStatus.Text = Ex.Message;
return false;
}
}

protected void ddlAction_SelectedIndexChanged(object sender, EventArgs e)
{
radYes.Checked = System.Convert.ToBoolean(ddlAction.SelectedItem.Value);
radNo.Checked = !(radYes.Checked);
txtName.Text = ddlAction.SelectedItem.Value;
}
}
mengxj85 2008-12-09
  • 打赏
  • 举报
回复
关注
fuzijing 2008-12-09
  • 打赏
  • 举报
回复
我汗 slickupload 的demo使用了

它也是不能多选的.....

fuzijing 2008-12-09
  • 打赏
  • 举报
回复
to ershou007 :一次多选的 老大

slickupload 收费的?? 官方站全是en文,免费的版本找晕了!
希望能给份!
ershou007 2008-12-09
  • 打赏
  • 举报
回复
多放几个UploadFile不就可以了
ttg520 2008-12-09
  • 打赏
  • 举报
回复
up
wuyq11 2008-12-09
  • 打赏
  • 举报
回复
参考
http://www.cnblogs.com/Dragon-China/archive/2007/07/13/817393.html
http://www.cnblogs.com/homer/archive/2008/01/04/1025984.html
http://www.cnblogs.com/Fooo/archive/2006/11/07/553104.html
http://www.cnblogs.com/wengjinbao/archive/2007/06/19/788639.html
zorou_fatal 2008-12-09
  • 打赏
  • 举报
回复
slickupload

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧