How to use Ajax file uploader in asp.net c#

In this article, we will discuss that how to use Ajax file uploader in asp.net c#, Many time we want to save multiple files on one time .
Source Code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ajaxfileuploader.aspx.cs"
    Inherits="ajaxfileuploader" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <div>
        <asp:AjaxFileUpload ID="Ajaxfileupload1" runat="server" MaximumNumberOfFiles="10"
            ToolTip="Please Upload All ID Proof Of Technician" OnUploadComplete="AjaxFileUploadEvent"
            Width="500px"></asp:AjaxFileUpload>
    </div>
    </form>
</body>
</html>


Code behind(c#):-
    protected void AjaxFileUploadEvent(object sender, AjaxFileUploadEventArgs e)
    {
        string filename = System.IO.Path.GetFileName(e.FileName);
       

        Ajaxfileupload1.SaveAs(Server.MapPath("~/files/") + filename);
    }

Out-Put:-


Note :-1 we can download Download ASP.Net AJAXControl Toolkit

2. We need to create to a folder with files name in Solution Explorer 
How to use Ajax file uploader in asp.net c# How to use Ajax file uploader in asp.net c# Reviewed by NEERAJ SRIVASTAVA on 1:45:00 PM Rating: 5

No comments:

Powered by Blogger.