Example Upload File - ASP.NET

This is example of upload file using asp.net.


 <fieldset style="width: 804px" align="center">
        <legend><em>Using the FileUpload Control</em>&nbsp;</legend>
        <div align="left" style="text-align: center">
            <form id="form1" runat="server">
                    <table style="width: 90%">
                            <td colspan="2">
                                <br />
                                <asp:Label ID="LSuccessMssg" runat="server"></asp:Label>
                                <asp:FileUpload ID="FileUpload1" runat="server" /><asp:Button ID="buttonUpload" runat="server"
                                    Text="Upload" OnClick="buttonUpload_Click1" /></td>

Code Behind

 protected void UploadThisFile(FileUpload upload)
        if (upload.HasFile)
            string theFileName = Path.Combine(Server.MapPath("~/Uploads"), upload.FileName);
            if (File.Exists(theFileName))

    protected void buttonUpload_Click1(object sender, EventArgs e)
        LSuccessMssg.Text = "Successfully upload File";

NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Popular posts from this blog

Example to disable save as certain file type in SSRS Report Viewer

Phone book application example - Java

Modal Popup Message Box ASP.NEt C# Example