Front-endCode:
<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "default. aspx. cs" inherits = "webapplication1. _ default" %>
<! 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> No title page </title>
<SCRIPT src = "jquery/jquery. js" type = "text/JavaScript" Language = "JavaScript"> </SCRIPT>
<SCRIPT src = "jquery/jquery. Multifile. js" type = "text/JavaScript" Language = "JavaScript"> </SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Fieldset>
<Asp: fileupload id = "fileupload1" runat = "server" Class = "multi"Maxlength = "2" />
<Asp: button id = "btnupload" runat = "server" text = "button" onclick = "btnupload_click"/>
</Fieldset>
</Div>
</Form>
</Body>
</Html>
Background code: Protected void Btnupload_click ( Object Sender, Eventargs E)
{
Try
{
Httpfilecollection HFCs = request. files;
For ( Int I = 0; I {
Httppostedfile HPF = hfc[ I];
If (HPF. contentlength> 0)
{
HPF. saveas (server. mappath ( "Myfile" ) +"\\"
+ System. Io. Path . Getfilename (HPF. filename ));
Response. Write ( "<SCRIPT> alert ('file uploaded successfully! ') </SCRIPT>" );
}
}
}
Catch ( Exception Ex)
{
Throw Ex;
}
}
:
Jquery plugin download:/files/ly5201314/multiple-file-upload.zip,
You only need to reference two JS files: jquery. js; jquery. Multifile. js. Class = "multi"Maxlength = "2"Is the key code.