I think better to try with mimetype than checking extension. Because, sometimes files can be exist without it and those are working very well in linux and unix systems.
So, you can try something like this:
["image/jpeg", "image/png", "image/gif"].indexOf(file.type) > -1