Reputation: 5179
I am using Regular Expression validator with file upload (Asp.Net) control in-order to restrict the files uploaded. My regular expression is as follows:
^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.wmv|.avi|.mpeg|.MPEG|.mp4|.MP4|.flv|.f4v)$
It gives error message of the validator even after uploading the right file in Firefox. But it works fine in IE.
Any one please help me providing a browser compatible way to validate my file upload control.
Upvotes: 0
Views: 2790
Reputation: 5179
t 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.
Use javascript to do the validation instead of regular expression validator.
var fileName = fupID.value; var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
if (ext == "wmv" || ext == "WMV" || ext == "avi" || ext == "AVI" || ext == "mp4" || ext == "MP4" || ext == "flv" || ext == "FLV" || ext == "F4V" || ext == "f4v" || ext=="mpg" || ext=="MPG" || ext=="mpeg" || ext=="MPEG" || ext=="mov" || ext=="MOV") {
// do required code logic here
}
Upvotes: 1