How to Upload Any File in ASP.NET

Hi Developers, Today’s Article, how to upload any file using ASP.NET in C#. We can upload any file such as Text file, Video File , Image , Zip File etc using File Upload Control in ASP.NET. To Achieve the output we need to take one File-upload control , one Button Control and one Label Control. See in below image.

To Achieve upper image design. copy and paste below codes.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            width: 214px;
        }
        .auto-style3 {
            text-decoration: underline;
            color: #000066;
            font-size: x-large;
        }
        .auto-style4 {
            background-color: #00CC66;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <span class="auto-style3"><strong><em><span class="auto-style4">How to Upload Any File in ASP.NET</span></em></strong></span><br />
            <table class="auto-style1">
                <tr>
                    <td class="auto-style2">
                        <asp:FileUpload ID="FileUpload1" runat="server" />
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style2">
                        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Upload" />
                    </td>
                    <td>
                        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="auto-style2">
                        <table class="auto-style1">
                            <tr>
                                <td>&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                    <td>&nbsp;</td>
                </tr>
            </table>
        </div>
    </form>
    <table class="auto-style1">
        <tr>
            <td>&nbsp;</td>
        </tr>
    </table>
</body>
</html>

Double Click on Button Control and write below given codes.

Try All. i hope you upload file without any issue. happy coding. thanks.

Post Author: adama