ASP.NET 2.0 FileUpload control tutorial

by Steven Ng on February 12, 2007

In this tutorial I will show how to write C# code that handles the FileUpload control. We will use the RegularExpressionValidator control for client-side validation and introduce server-side validation methods when uploading specific file types.

coming soon…

5 comments

I need to validate the filename while browsing and uploading a file such tat,it should allow only .xls files

by Smitha on June 29, 2007 at 12:23 am. #

Hi Smitha, you can use the RegularExpressionValidator control to check the uploaded file for the pattern “*.xls” and also check the ContentType property as “application/excel” in case someone just changes the file name extension and attempts to upload the file.

by Steve on July 15, 2007 at 1:42 pm. #

Is it possible to change it to where it only shows a specific file type when browsing? I am thinking I am going to have to make this my first ever custom control because I only want to see the .pdf files in the folders when I browse.

by laura on February 8, 2008 at 1:38 pm. #

You are an asshole! Why you post an article you have’t write yet? Are you stupid or what??

by Nahuel on October 30, 2008 at 10:21 am. #

Hey Nahuel, sorry about not finishing the post. I’ve been trying to find a way to consolidate all my blogs/projects so I can maintain them more efficiently so I don’t piss off readers like you.

by Steve on December 12, 2008 at 9:21 pm. #

Leave your comment

Required.

Required. Not published.

If you have one.