Multi-file upload h3>
p>
asp: button>
P>
BorderStyle = "none" bordercolor = "white"> asp: label>
P>
div>
form>
body>
Html>
Code part
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;
Namespace WebPortal
{
///
/// UPLOAD summary description.
// / Implement multiple file upload
/// summary>
Public class upload: system.Web.ui.page
{
protected system.web.ui.webcontrols.button uploadbutton;
Protected system.web.ui.webcontrols.label strstatus;
Private Void Page_Load (Object Sender, System.EventArgs E)
{
/// Place the user code here to initialize the page
IF (this.ispostback) .saveImages ();
}
Private Boolean SaveImages ()
{
/// 'Traversed File form elements
HTTPFILECOLLECTION FILES = httpContext.current.Request.files;
/// 'status information
System.Text.StringBuilder strmsg = new system.text.stringbuilder ();
STrmsg.Append ("Uploaded files is:
");
Try
{
For (int ifile = 0; ifile
{
/// 'Check the file extension name
Httppostedfile postedfile = files [ifile];
String FileName, FileExtension;
Filename = system.io.path.GetFileName (postedfile.filename);
IF (filename! = "")
{
FileExtension = system.io.path.Getextension (filename);
strmsg.append ("Uploaded File Type:" PostedFile.ContentType.toString () "
);
STRMSG.Append ("Client File Address:" PostedFile.FileName "
");
strmsg.append ("" "Upload file name:" filename "
");
STRMSG.Append ("" "Upload Document Extension:" FileExtension
");
/// 'Save to different folders according to the different names
/// Note: You may want to modify anonymous write permission for your folder. 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;
}
}
#Region web form designer generated code
Override protected void oninit (Eventargs E)
{
//
// Codegen: This call is necessary for the ASP.NET Web Form Designer.
//
InitializationComponent ();
Base.onit (e);
}
///
/// Designer supports the required method - do not use the code editor to modify
/// This method is content.
/// summary>
Private vidinitiRizeComponent ()
{
THIS.ID = "UPLOAD";
This.Load = New System.EventHandler (this.page_load);
}
#ndregion
}
}