Question

I have a FileUpload with a RegularExpressionValidator with the following Validation Expression:

^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.gif|.jpg|.JPG|.JPEG|.GIF|.jpeg|.png|.bmp|.3dm|.3dmf|.ai|.drw|.dxf|.esp|.mng|.png|.ps|.psp|.svg|.tiff)$

This way I make sure the User only upload images. But for some reason it does not work when I use Firefox. Why is that and how can I go around the problem?

Was it helpful?

Solution 3

I found the solution.....

(.*\.([gG][iI][fF]|[jJ][pP][gG]|[jJ][pP][eE][gG]|[bB][mM][pP])$)

Link to the answer

Enjoy!!!

OTHER TIPS

Try this:

(.*?)\.(jpg|jpeg|png|gif)$

An enhancement to DaDa's solution that caters for case-sensitivity:

^(.*?)\.(((j|J)(p|P)(e|E)?(g|G))|((p|P)(n|N)(g|G))|((g|G)(i|I)(f|F)))$

I have got a solution to this problem:

var reg = /([^\s]+(?=.(jpg|gif|png|jpeg)).\2)/gm; 
if (reg.test(uploadcontrol) == false) { 
    alert("Please upload valid image formats(.jpg,.gif,.jpeg and .png)");
}

It does not work with Firefox v3.x because it does not allow JavaScript to get full path name from the file input field and this particular regular expression expects to see full path name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top