Home > DeveloperSection > Beginner > FileUpload Control in ASP.Net

FileUpload Control in ASP.Net

ASP.Net ASP.Net 
1 Comment(s)
 10931  View(s)
Rate this:

FileUplaod Control in ASP.Net

With the File Upload conrol we can allow user to upload file to the server.

<asp:FileUpload ID="FileUpload1" runat="server" />

FileUplaod Control in ASP.Net


<asp:FileUpload ID="FileUpload1" runat="server" ondatabinding="Button1_Click" />


<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Upload" />

<asp:Label ID="Label1" runat="server"></asp:Label>

protected void Button1_Click(object sender, EventArgs e)


if (FileUpload1.HasFile)

// HasFile check that there is any file available for uploading or not.


FileUpload1.SaveAs(Server.MapPath("~/NewFolder1/" +


Label1.Text = "File Uploaded";



Label1.Text = "You have not specified a file";


The Server.MapPath method maps a specified path to a physical path. In ASP.NET the ~ tilde indicates the root of a virtual path.

Run The Project

Now browse and select file  and click upload button then it will save the file in NewFolder1.

When you click Upload button then HasFile property of FileUpload control check that FileUpload control contain a file or not If there is a file then control will go for the next step (uploading) otherwise it will not.

FileUplaod Control in ASP.Net

We can change its appearance

<asp:FileUpload ID="FileUpload1" runat="server" Font-Bold="True"

  Font-Italic="True" Font-Names="Arial Black" ForeColor="Red" />

FileUplaod Control in ASP.Net


By Sunil Singh on   one month ago

It was really helpful to read this post.

Don't want to miss updates? Please click the below button!

Follow MindStick