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
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
I do not beleive this is possible. I have never seen a web page open a file selector dialog with a filter on.
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.
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!