Scenario: Allow only files of extensions jpg, gif, png and bmp.
The first code snippet I am presenting is valid but will only work on Microsoft Internet Explorer.
This code snippet is better since it will work on all browsers, including Microsoft Internet Explorer, Mozilla Firefox, Google Chrome and Apple Safari.
The second regular expression works because it checks only the file name i.e. it does not expect a full absolute path name.