图像的正则表达式? [英] Regular Expression for image?

查看:70
本文介绍了图像的正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用文件up-loader将图像上传到DB中。我已使用下面给出的代码,但它不起作用。如果我上传任何也插入数据库的pdf或doc文件,也会显示错误消息。如果文件不是图像格式,我想停止插入。帮我找一个合适的解决方案。谢谢。



ASPX:



 <   asp:FileUpload     ID   =  PhotoUpload1    runat   =  server    ForeColor   = #999999    /  >  <   asp:RegularExpressionValidator     ID   =  RegularExpressionValidator6    runat   =  server    ErrorMessage   =  * jpeg,gif,png    ControlToValidate   =  PhotoUpload1    ForeColor   = 红色    ValidationExpression   = 。* \。([gG] [iI] [fF] | [jJ] [pP] [gG] | [jJ] [pP] [eE] [gG] | [bB] [mM] [pP])$ >  <   / asp:RegularExpressionValidator  >  

解决方案

> < / asp:RegularExpressionValidator >


查看此链接hope这对你有帮助。



http://forums.asp.net/t/1125353.aspx?RegularExpressionValidator+with+FileUpload+control+posting+error+after+upload [ ^ ]



http:// stack overflow.com/questions/16585901/regularexpressionvalidator-error-message [ ^ ]

I have to upload images into DB using file up-loader. I have used the given below code, but it is not working. If I upload any pdf or doc file that also inserting into DB and the error message also displaying. I want to stop insertion if the file is not an image format. Help me to find a proper solution. Thank you.

ASPX:

<asp:FileUpload ID="PhotoUpload1" runat="server" ForeColor="#999999" /><asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" ErrorMessage="*jpeg,gif,png" ControlToValidate="PhotoUpload1" ForeColor="Red" ValidationExpression=".*\.([gG][iI][fF]|[jJ][pP][gG]|[jJ][pP][eE][gG]|[bB][mM][pP])$"></asp:RegularExpressionValidator>

解决方案

"></asp:RegularExpressionValidator>


Check this links hope this will help you.

http://forums.asp.net/t/1125353.aspx?RegularExpressionValidator+with+FileUpload+control+posting+error+after+upload[^]

http://stackoverflow.com/questions/16585901/regularexpressionvalidator-error-message[^]


这篇关于图像的正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆