28 March 2013

Multiple File Upload JQuery Asp.net

Multiple File Upload JQuery Asp.net in C#

MultipleFileUpload.aspx.cs


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MultipleFileUpload.aspx.cs"
    Inherits="MultipleFileUploadJquery.MultipleFileUpload" %>

Include the below script

    < script src="Scripts/jquery-1.8.2.js" type="text/javascript">
    < script src="Scripts/jquery.MultiFile.js" type="text/javascript">

Code

    < form id="form1" runat="server">
    < div >
       
         < asp:FileUpload ID="file_upload" class="multi" runat="server"  / >
        < asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" / >
        < asp:Label ID="lblMessage" runat="server" / >
       
    < /div >
    < /form >
< /body >
< /html >


MultipleFileUploadJquery,aspx.cs

using System;
using System.IO;
using System.Web;

namespace MultipleFileUploadJquery
{
    public partial class MultipleFileUpload : System.Web.UI.Page
    {  

        protected void btnUpload_Click(object sender, EventArgs e)
        {
            HttpFileCollection fileCollection = Request.Files;
            for (int i = 0; i < fileCollection.Count; i++)
            {
                HttpPostedFile uploadfile = fileCollection[i];
                string fileName = Path.GetFileName(uploadfile.FileName);
                if (uploadfile.ContentLength > 0)
                {
                    uploadfile.SaveAs(Server.MapPath("~/UploadFiles/") + fileName);
                    lblMessage.Text += fileName +""+ "Saved Successfully";
                }
            }
        }

    }
}


Multifile upload Code in C# Visual Studio 2010 are in the following path

http://sdrv.ms/103livW







No comments:

Post a Comment

Comments Welcome

Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...