This tutorial will show you how to perform a File Upload using ASP.NET 2.0, the FileUpload control, and VB .NET

The .NET Framework offers the FileUpload control to simplify uploading files from web pages.

We’ll put our code in the btnSubmit_Click() event.

When the btnSubmit_Click() event fires it first checks to see if the user selected a file. It then defines a pattern to extract the filename and extension. Once the pattern is matched it calls the fileUpEx.PostedFile.SaveAs() method with the complete path the file should be saved to In this case we are concatenating the Server.MapPath(“.”) (current directory) and the filename.

We have the FileUpload control itself, a submit button and a label on the front end for user interaction. The front end .aspx page looks something like this:

The flow for the code behind page is as follows:

Download Source Files