This tutorial will show you how to use the FileUpload control in Visual Basic.NET. By using the FileUpload control we are able to upload files to a specified location on the hard drive. Once a file is uploaded to the server, a lot of possibilities are available to the web site. For example, when people upload files to a web site it is usually for others to download, so when it is uploaded to the server it can turn around and put it up for download on the web site.

Setting Up

If you have not done so already, open Visual Studio and create an empty web site based on the Visual Basic template. Add a web form and leave the name as Default.aspx.

Step One

In the open div tags, place a FileUpload, Label, and Button control. Change the text of the Button control to “Upload” and place break tags between the controls to create a clean look on the web page.

The FileUpload control allows the user to browse for a file on their computer to upload. When the Button control is clicked, the file will be uploaded and the Label control will display information about the file uploaded.

Step Two

Switch to design view and double click the Button control to create an event handler method in the code behind page. In this click event we will upload a file if available and save it to “C:\Uploads”. If there is no “Uploads” folder in the “C:” drive, then we will throw an exception as well as thrown an error if the user tries uploading a file without first selecting one.


Run the page and you will see a browse button, click it and look for a file. Click the “Upload” button and and if no error is thrown, the label will display information about the file and also where the file has been uploaded to.

upload file 1

Thanks for reading and make sure to download the source files to get a better understanding of how the code works.

Download Source Files