开发者

How to add filtering to the File Explorer opened by the asp:UploadFile control

开发者 https://www.devze.com 2022-12-13 11:59 出处:网络
Is there any way to open the file explorer setting the filtering options like a des开发者_Go百科ktop application does?, and I don\'t want to validate the file after is selected, I want my users to vie

Is there any way to open the file explorer setting the filtering options like a des开发者_Go百科ktop application does?, and I don't want to validate the file after is selected, I want my users to view only valid files throught filtering them before.


NO, this is not possible using the asp:FileUpload Control.

How to filter files in file upload control

seems like there is a way using JavaScript.


There is an "accept" attribute which can be set for the upload control however as discussed here, many browsers don't impliment this attribute.

Your best bet is to use Javascript as astander recommends so that you can check the extension of the file being uploaded before it hits the server.

You'll also want to do a check on the server side since client-side validation cannot be relied on for this type of thing.


No, for web applications there is no way yet (Dec 2009) to set the File Selector filtering. According to the INPUT tag (used by the UploadFile control to render) documentation it should be possible by adding the 'accept' attribute and setting the file mime type(s)... so bad that any major browser supports the accept attribute of input tags.

The best workaround is to validate the files on the client and server side.

0

精彩评论

暂无评论...
验证码 换一张
取 消