Upload Multiple Files Using jQuery

Upload Multiple Files Using jQuery :

 

.aspx page code :->

<%@ Page Language=”C#” AutoEventWireup=”true”  CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head runat=”server”>
<title>Upload Multiple Files in ASP.NET Using jQuery</title>
<script src=”Scripts/jquery-1.3.2.js” type=”text/javascript”></script>
<script src=”Scripts/jquery.MultiFile.js” type=”text/javascript”></script>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:FileUpload ID=”FileUpload1″ runat=”server” />
<br />
<asp:Button ID=”btnUpload” runat=”server” Text=”Upload All”
onclick=”btnUpload_Click” />
</div>

</form>
</body>
</html>

——————————

.cs page :–>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnUpload_Click(object sender, EventArgs e)
{
try
{
// Get the HttpFileCollection
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath(“MyFiles”) + “\\” +
System.IO.Path.GetFileName(hpf.FileName));

Response.Write(“<b>File: </b>” + hpf.FileName + ”  <b>Size:</b> ” +
hpf.ContentLength + ”  <b>Type:</b> ” + hpf.ContentType + ” Uploaded Successfully <br/>”);
}
}
}
catch (Exception ex)
{

}
}
}

Refer this link for full source  code :–>http://www.codeproject.com/Articles/68374/Upload-Multiple-Files-in-ASP-NET-using-jQuery

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s