The JavaScript code below checks the the file selected by the user is an image file. For added security make sure your file select element enforces this as well via the ACCEPT attribute ...
<input accept="image/gif,image/png,image/jpeg" id="idOfImageFileControl" name="inputfilephoto" type="file">