0
We can upload images very easily using File upload control in asp.net, also you can validate the upload the file type using Reguler expression validator, following is the regular expression validation control code for validating image types such as jpg, png and bmp.
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ErrorMessage="Upload a valid image (jpg/png/bmp)"
ValidationExpression ="^.+\.((jpg)(JPG)(gif)(GIF)(jpeg)(JPEG)(png)(PNG)(bmp)(BMP))$"
ControlToValidate="fupImage" ValidationGroup="Author_reg"> Upload a valid image;</asp:RegularExpressionValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ErrorMessage="Upload a valid image (jpg/png/bmp)"
ValidationExpression ="^.+\.((jpg)(JPG)(gif)(GIF)(jpeg)(JPEG)(png)(PNG)(bmp)(BMP))$"
ControlToValidate="fupImage" ValidationGroup="Author_reg"> Upload a valid image;</asp:RegularExpressionValidator>
Post a Comment