HTML部分
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="up6.index" %>
var cbMgr = new HttpUploaderMgr();
cbMgr.event.md5Complete = function (obj, md5) { /*alert(md5);*/ };
cbMgr.event.fileComplete = function (obj) { /*alert(obj.fileSvr.pathSvr);*/ };
cbMgr.event.queueComplete = function () { $(document.body).append("队列完成
"); }
cbMgr.event.addFdError = function (jv) { alert("本地路径不存在:" + jv.path); };
cbMgr.event.scanComplete = function (obj) { /*alert(obj.folderSvr.pathLoc);*/ };
cbMgr.Config["Cookie"] = 'ASP.NET_SessionId=<%=Session.SessionID%>';
cbMgr.Config.Fields["uid"] = 0;
$(function ()
{
cbMgr.load_to("FilePanel");
//上传指定文件
$("#btnUpF").click(function () {
var path = $("#filePath").val();
cbMgr.app.addFile({ pathLoc: path });
});
//上传指定目录
$("#btnUpFd").click(function () {
var path = $("#folderPath").val();
cbMgr.app.addFolder({ pathLoc: path });
});
});
up6多标签上传演示页面
清空数据库
文件管理器演示
单面板演示
打开下载页面
单文件上传演示
文件路径:
目录路径:
代码部分
usingSystem;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Web;
usingSystem.Web.SessionState;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.HtmlControls;
namespaceWebPortal
{
///
///UpLoad 的摘要说明。
/// 实现多文件上传
///
public classUpload :System.Web.UI.Page
{
protectedSystem.Web.UI.WebControls.ButtonUploadButton;
protectedSystem.Web.UI.WebControls.LabelstrStatus;
private voidPage_Load(objectsender,System.EventArgse)
{
/// 在此处放置用户代码以初始化页面
if (this.IsPostBack) this.SaveImages();
}
privateBooleanSaveImages()
{
///'遍历File表单元素
HttpFileCollectionfiles =HttpContext.Current.Request.Files;
///'状态信息
System.Text.StringBuilderstrMsg = newSystem.Text.StringBuilder();
strMsg.Append("上传的文件分别是:");
try
{
for(intiFile =0;iFile
{
///'检查文件扩展名字
HttpPostedFilepostedFile =files[iFile];
stringfileName,fileExtension;
fileName =System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
fileExtension =System.IO.Path.GetExtension(fileName);
strMsg.Append("上传的文件类型:" +postedFile.ContentType.ToString() + "
");
strMsg.Append("客户端文件地址:" +postedFile.FileName + "
");
strMsg.Append("上传文件的文件名:" +fileName + "
");
strMsg.Append("上传文件的扩展名:" +fileExtension + "
");
///'可根据扩展名字的不同保存到不同的文件夹
///注意:可能要修改你的文件夹的匿名写入权限。
postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("images/") +fileName);
}
}
strStatus.Text =strMsg.ToString();
return true;
}
catch(System.ExceptionEx)
{
strStatus.Text =Ex.Message;
return false;
}
}
#regionWeb 窗体设计器生成的代码
override protected voidOnInit(EventArgse)
{
//
//CODEGEN: 该调用是ASP.NETWeb窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
/// 设计器支持所需的方法-不要使用代码编辑器修改
/// 此方法的内容。
///
private voidInitializeComponent()
{
this.ID = "Upload";
this.Load += newSystem.EventHandler(this.Page_Load);
}
#endregion
}
}
选择文件夹
js部分
后端代码逻辑大部分是相同的,目前能够支持MySQL,Oracle,SQL。在使用前需要配置一下数据库,详细信息可以网上搜索“up6”大文件上传控件