Introduction
You have to use Regular Expression to restrict the File types from being uploaded.Here I am going to show how to restrict it.
<asp:RegularExpressionValidator ID="rev" runat="server" ControlToValidate="fuupload" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.txt|.TXT|.xls|.XLS)$" ErrorMessage="Only Image File are allowed."></asp:RegularExpressionValidator>
If above method is not working for Image File then Please use Below.its working well in all browser.
<asp:RegularExpressionValidator ID="rev" runat="server" ControlToValidate="fuupload" ValidationExpression="(.*\.([gG][iI][fF]|[jJ][pP][gG]|[jJ][pP][eE][gG]|[bB][mM][pP])$)" ErrorMessage="Only Image File are allowed."></asp:RegularExpressionValidator>
You have to use Regular Expression to restrict the File types from being uploaded.Here I am going to show how to restrict it.
<asp:RegularExpressionValidator ID="rev" runat="server" ControlToValidate="fuupload" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.txt|.TXT|.xls|.XLS)$" ErrorMessage="Only Image File are allowed."></asp:RegularExpressionValidator>
If above method is not working for Image File then Please use Below.its working well in all browser.
<asp:RegularExpressionValidator ID="rev" runat="server" ControlToValidate="fuupload" ValidationExpression="(.*\.([gG][iI][fF]|[jJ][pP][gG]|[jJ][pP][eE][gG]|[bB][mM][pP])$)" ErrorMessage="Only Image File are allowed."></asp:RegularExpressionValidator>
0 comments:
Post a Comment