views:

440

answers:

3

how to filter the file type with the file upload control in asp.net & c#.net

for example on clicking the browse button of the file upload control ,it should open browse file dialog with only excel file types.

how is it possible

A: 

I do not beleive this is possible. I have never seen a web page open a file selector dialog with a filter on.

Ben Robinson
A: 

I think this is not possible with <input type="file" control.

I've heard about SWFUploader which allows to define extensions for files to upload but this is flash component.

And even if you will use SWFUploader, nobody won't be able to prevent you from type *.* and selecting any file to upload.

Alex
A: 

You can use C1Upload from ComponentOne to do this. It has support for file type and size validation. Keep in mind, you will want to also validate on the server since file extensions can easily be changed to mismatch their actual type. This is a standard in any validation practice: validate in the UI layer then validate at the BL layer and preferably validate at the DL too. Here is a demo of the ASP.NET AJAX upload control with built-in validation.

Another cool thing about this control is that is supports multiple upload files and shows upload progress!

Banzor