When you use file control from the input tag then for validation purpose you need to check the file name. if no file is selected then an error message should be displayed. This post will help you to achieve the same. When a user doesn’t select a file and an attempt is made to read file name then JS engines throw an exception which must be caught otherwise you will not be able to read and validate the empty file.
<input type="file" class="upload" onchange="readURL(this)" id="fileRO" accept="image/x-png,image/jpeg" />
alert('Please select a image file');