在IE中一次选中多个文件进行上传(不是多个FILE框进行选择),如有人提供原代码和控件者价格可以商量!
解决方案 »
- 两个DIV并排的问题
- 根据CheckBox打勾查询DataList数据,并跳转到下面的隐藏层
- 3行的小问题~~~~~~~~~~~~
- 做这个网站要多少钱?给个公司价和个人做的价格。给个理由。来者有份。
- asp.net一个小问题?
- 拟购买.NET论坛代码,做为大型游戏论坛用
- asp.net搜索小偷C# 乱码问题
- 给各位推荐一本热门好书,《你在为谁工作》
- csdn左边这颗树怎样能打开一个分枝后,自动合上其余的分枝?
- 如何使用Swftools将pdf文件转化为swf文件。
- 各位大侠,我看到领航OA里说把MSN集成到OA里去了。请问一下是怎么实现的啊?
- 如何让一条数据记录,不在dataGird中显示。???
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using Bestcomy.Web.Controls.Upload;namespace AspNetUpload
{
/// <summary>
/// MultiUpload 的摘要说明。
/// </summary>
public class MultiUpload : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox box_comments;
protected System.Web.UI.WebControls.Label txt_result;
protected System.Web.UI.WebControls.Button btn_upload;
private void Page_Load(object sender, System.EventArgs e)
{
BestcomyUpload upldr = new BestcomyUpload();
upldr.RegisterProgressBar("ProgressBar.aspx",btn_upload); //注册上传进度条。
string fpath = Path.Combine(Server.MapPath("."),"Upload");
if(!Directory.Exists(fpath))
Directory.CreateDirectory(fpath);
upldr.UploadFolder=fpath; //设置上传文件临时目录,要求ASPNET用户对该文件夹有写权限。
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btn_upload.Click += new System.EventHandler(this.btn_upload_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion /// <summary>
/// 获取最大可上传文件大小。
/// </summary>
/// <returns></returns>
protected double GetMaxRequestLength()
{
double maxLength=0;
string sPath = typeof(String).Assembly.Location;
sPath = Path.GetDirectoryName(sPath);
sPath = Path.Combine(sPath,"CONFIG\\machine.config");
XmlDocument doc=new XmlDocument();
doc.Load(sPath);
maxLength=Convert.ToDouble(doc.SelectSingleNode("configuration/system.web/httpRuntime/@maxRequestLength").Value);
doc.Load(Path.Combine(Request.PhysicalApplicationPath,"web.config"));
XmlNode node=doc.SelectSingleNode("configuration/system.web/httpRuntime/@maxRequestLength");
if(node!=null)
{
double length=Convert.ToDouble(node.Value);
if(length<maxLength)
maxLength=length;
} return maxLength/1024;
} private void btn_upload_Click(object sender, System.EventArgs e)
{
string fpath = Path.Combine(Server.MapPath("."),"Upload"); StringBuilder sb = new StringBuilder();
sb.Append("<hr>说明文字:"+box_comments.Text+"<br>");
sb.Append("上传文件列表:<br>");
sb.Append("<table border='1'>");
sb.Append("<tr><td>文件名</td><td>大小</td></tr>"); BestcomyUpload upldr = new BestcomyUpload();
foreach(UploadFile file in upldr.GetUploadFiles("file1"))
{
file.SaveAs(Path.Combine(fpath,Path.GetFileName(file.FileName)));
sb.Append("<tr><td>"+Path.GetFileName(file.FileName)+"</td><td>"+file.ContentLength.ToString("###,###")+" 字节</td></tr>");
}
sb.Append("<table>");
txt_result.Text = sb.ToString();
}
}
}