Sección HTML
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "index.aspx.cs" Inherits = "up6.index"%>
<! DOCTYPE html PUBLIC "- // W3C // DTD XHTML 1.0 Transitional // ES" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "Content-Type" content = "text / html; charset = gb2312" />
<title> up6-multi-tab demo page </ title>
<link href = "js / up6.css" type = "text / css" rel = "Stylesheet" charset = "gb2312" />
<script type = "text / javascript" src = "js / jquery-1.4.min.js"> </script>
<script type = "text / javascript" src = "js / json2.min.js" charset = "utf-8"> </script>
<script type = "text / javascript" src = "js / up6.config.js" charset = "utf-8"> </script>
<script type = "text / javascript" src = "js / up6.app.js" charset = "utf-8"> </script>
<script type = "text / javascript" src = "js / up6.edge.js" charset = "utf-8"> </script>
<script type = "text / javascript" src = "js / up6.file.js" charset = "utf-8"> </script>
<script type = "text / javascript" src = "js / up6.folder.js" charset = "utf-8"> </script>
<script type = "text / javascript" src = "js / up6.js" charset = "utf-8"> </script>
<script language = "javascript" type = "text / javascript">
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 ("队列 完成 <br/>"); }
cbMgr.event.addFdError = function (jv) {alert ("La ruta local no existe:" + 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");
// Sube el archivo especificado
$ ("# btnUpF"). haga clic en (function () {
var ruta = $ ("# filePath"). val ();
cbMgr.app.addFile ({pathLoc: ruta});
});
// Sube el directorio especificado
$ ("# btnUpFd"). haga clic en (function () {
var ruta = $ ("# folderPath"). val ();
cbMgr.app.addFolder ({pathLoc: ruta});
});
});
</script>
</head>
<cuerpo>
<p> up6 página de demostración de carga de múltiples pestañas </ p>
<p> <a href="db/clear.aspx" target="_blank"> 清空 数据库 </a> </p>
<p> <a href="filemgr/index.aspx" target="_blank"> Demo del administrador de archivos </a> </ p>
<p> <a href="index2.aspx" target="_blank"> Demostración de panel único </a> </ p>
<p> <a href="down2/index.htm" target="_blank"> Abra la página de descarga </a> </ p>
<p> <a href="index-single.htm" target="_blank"> Demo de carga de un solo archivo </a> </ p>
<p>
文件 路径 : <input id = "filePath" type = "text" size = "50" value = "D: \\ 360safe-inst.exe" /> & nbsp;
<input id = "btnUpF" type = "button" value = "Cargar archivo local" />
</p>
<p>
目录 路径 : <input id = "folderPath" type = "text" size = "50" value = "C: \\ Users \\ Administrator \\ Desktop \\ test" /> & nbsp;
<input id = "btnUpFd" type = "button" value = "Cargar directorio local" />
</p>
<div id = "FilePanel"> </div>
<div id = "msg"> </div>
</body>
</html>
Sección de código
utilizando el sistema;
usando System.Collections;
utilizando System.ComponentModel;
usando System.Data;
usando System.Drawing;
usando System.Web;
usando System.Web.SessionState;
usando System.Web.UI;
utilizando System.Web.UI.WebControls;
utilizando System.Web.UI.HtmlControls;
espacio de nombres WebPortal
{
/// <resumen>
/// Descripción resumida de UpLoad.
/// Implementa la carga de múltiples archivos
/// </summary>
Carga de clase pública: System.Web.UI.Page
{
System.Web.UI.WebControls.Button UploadButton protegido;
System.Web.UI.WebControls.Label strStatus protegido;
privado vacío Page_Load (remitente del objeto, System.EventArgs e)
{
/// Coloque el código de usuario aquí para inicializar la página
if (this.IsPostBack) this.SaveImages ();
}
Private Boolean SaveImages ()
{
/// 'Recorrer el elemento de formulario Archivo
HttpFileCollection files = HttpContext.Current.Request.Files;
/// 'Información de estado
System.Text.StringBuilder strMsg = new System.Text.StringBuilder ();
strMsg.Append ("Los archivos cargados son: <hr color = red>");
tratar
{
for (int iFile = 0; iFile <archivos.Count; iFile ++)
{
/// 'Comprueba el nombre de la extensión del archivo
HttpPostedFile postedFile = files [iFile];
string fileName, fileExtension;
fileName = System.IO.Path.GetFileName (postedFile.FileName);
if (fileName! = "")
{
fileExtension = System.IO.Path.GetExtension (fileName);
strMsg.Append ("Tipo de archivo cargado:" + postedFile.ContentType.ToString () + "<br>");
strMsg.Append ("Dirección del archivo del cliente:" + postedFile.FileName + "<br>");
strMsg.Append ("Nombre de archivo del archivo cargado:" + fileName + "<br>");
strMsg.Append ("Extensión del archivo cargado:" + fileExtension + "<br> <hr>");
/// 'se puede guardar en diferentes carpetas de acuerdo con diferentes nombres de extensión
/// Nota: es posible que deba modificar el permiso de escritura anónimo de su carpeta.
postedFile.SaveAs (System.Web.HttpContext.Current.Request.MapPath ("images /") + fileName);
}
}
strStatus.Text = strMsg.ToString ();
volver verdadero;
}
catch (System.Exception Ex)
{
strStatus.Text = Ex.Message;
falso retorno;
}
}
Código generado por #region Web Form Designer
anular vacío protegido OnInit (EventArgs e)
{
//
// CODEGEN: Esta llamada es requerida por el Diseñador de formularios web ASP.NET.
//
InitializeComponent ();
base.OnInit (e);
}
/// <resumen>
/// El diseñador admite el método requerido; no utilice el editor de código para modificar
/// El contenido de este método.
/// </summary>
private void InitializeComponent ()
{
this.ID = "Cargar";
this.Load + = new System.EventHandler (this.Page_Load);
}
#endregion
}
}
Elegir carpeta
js parte
La lógica del código de fondo es casi la misma, y actualmente es compatible con MySQL, Oracle, SQL. Antes de usar, debe configurar la base de datos, puede consultar este artículo que escribí: http://blog.ncmem.com/wordpress/2019/08/07/java carga y descarga de archivos enormes /
Bienvenido a unirse al grupo para discutir: 374992201