如何过滤FileUpload Control?

ghi*_*hie 4 .net regex asp.net file-upload

如何在asp.net中向fileupload控件添加过滤器?我想要一个Oasis File(.000)的过滤器.

请指教我...非常感谢!

Muh*_*tar 5

您可以使用 RegularExpressionValidator

<asp:RegularExpressionValidator ID="rexp" runat="server" ControlToValidate="fupProduct"
     ErrorMessage="Only .gif, .jpg, .png, .tiff and .jpeg" 
     ValidationExpression="(.*\.([Gg][Ii][Ff])|.*\.([Jj][Pp][Gg])|.*\.([Bb][Mm][Pp])|.*\.([pP][nN][gG])|.*\.([tT][iI][iI][fF])$)"></asp:RegularExpressionValidator>
Run Code Online (Sandbox Code Playgroud)