---
title: "FileUpload Control in ASP.Net"  
description: "With the File Upload conrol we can allow user to upload file to the server.  aspFileUploadID=\"FileUpload1\"runat=\"server\"Code:aspFileUploadID=\"FileUplo"  
author: "Pushpendra Singh"  
published: 2010-10-22  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/176/fileupload-control-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# FileUpload 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](https://www.mindstick.com/mindstickarticle/c323d0d8-495e-46c6-a12d-024908aa7a29/images/169a9b8b-baa7-4d91-a58e-6d972536811d.png)

##### Code:

```
<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/" +FileUpload1.FileName));Label1.Text = "File Uploaded"; } elseLabel1.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](https://www.mindstick.com/mindstickarticle/c323d0d8-495e-46c6-a12d-024908aa7a29/images/09d980d1-0ef9-4163-87ad-b4eca65aa96d.png)

```
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](https://www.mindstick.com/mindstickarticle/c323d0d8-495e-46c6-a12d-024908aa7a29/images/7dbfb892-c647-41bb-84ac-2f013771d641.png)

\

---

Original Source: https://www.mindstick.com/articles/176/fileupload-control-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
