How to clear a file input?

I have a file input
<input type="file" id="files" name="files[]" multiple style="width:100%;" required/>
And when I the first time try to send without an image then it shows the alert “Select a file”, so the “required” is working as it should.

But when I have uploaded an image Im clearing the file input like this

and I have tried with this as well


When I then try to upload without an image, the “required” is not working?