This is quite a handy and much needed script.
However i think if you would have added a check for webcam availabilty it would have been complete.
Idea is say an admin panel or user panel where they need to upload their
photo, if webcam is available , an option would be provided to get their
photo from webcam and upload that.