Hi,
Use below JQuery Plug-in it will help you.
jquery-1.4.min.js
jquery.MultiFile.pack.js
Aspx:
<script src="jquery-1.4.min.js" type="text/javascript" language="javascript"></script>
<!-- Download the MultiFile upload jQuery plug in from
http://www.fyneworks.com/jquery/multiple-file-upload -->
<script language="javascript" src="jquery.MultiFile.pack.js" type="text/javascript"></script>
Select files to upload:
<asp:FileUpload ID="FileUpload1" runat="server" class="multi" accept="png|jpg|aspx" />
<p><asp:Button ID="Button3" runat="server" Text="Upload Files using jQuery" OnClick="jQueryUploadFiles" /></p>
C# Code:
protected void jQueryUploadFiles(object sender, EventArgs
{
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
string path = Server.MapPath("~/");
string fileName = file.FileName;
if (file.ContentLength > 0)
{
// now save the file to the disk
file.SaveAs(path + fileName);
}
Response.Write(fileName + " uploaded successfully ! <br />");
}
}
also you use below .net code
Upload files<br />
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:FileUpload ID="FileUpload2" runat="server" /><br />
<asp:FileUpload ID="FileUpload3" runat="server" /><br />
<asp:FileUpload ID="FileUpload4" runat="server" /><br />
<p><asp:Button ID="btnUpload" runat="server" Text="Upload Multiple Files" OnClick="UploadMultipleFiles" /></p>
C# code:
protected void UploadMultipleFiles(object sender, EventArgs e)
{
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
string path = Server.MapPath("~/");
string fileName = file.FileName;
file.SaveAs(path + fileName);
Response.Write(fileName + " uploaded successfully ! <br />");
}
}
Anurag_Sharma4u, if this helps please login to Mark As Answer. | Alert Moderator