JumpStart # 12–Multiple File Upload in ASP.Net 4.5

Before looking at the code, Read about – What is JumpStart?

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, EventArgs e)
        // Check for FileUpload Control got any Files
        if (FileUpload1.HasFiles)
            // Iterate FileUpload Controls Files
            foreach (HttpPostedFile file in FileUpload1.PostedFiles)
                file.SaveAs(Server.MapPath("~/Images/") + file.FileName);

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
        <!-- Use the Regular FileUpload Control, but with AlloMultiple="true" attribute -->
        <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />


Solution Structure –


You may also like...