in this input field, it will only accept video files. if I try to upload any other files, by enabling all files option. it will show a alert. that's working fine but after adding any other format file, when it checking that it is not a video file, it showing the alert but file name is remaining in the input field.
I want to clear the input field file name and e.target.files as clear.
this is my code...
<Label for="exampleFile">Upload Video</Label>
<MyInput
type="file"
name="file"
accept="video/*"
id="exampleFile"
label="Upload a Video"
onChange={(e) => {
let files = e.target.files;
let file = files[0];
let name = files[0].name;
let type = files[0].type;
if (!file.type.match("video.*")) {
alert("You Can't upload a video file ");
} else {
// some code
}
}}
/>
when I am uploading any other format, it showing the alert, After clicking the OK button.it is showing....
the file name is still in the input field. I have to reset it.
I have tried with...
document.getElementById('exampleFile').value = nulluseRef()- added a
valueproperty withuseState()but nothing is working.
can anyone help me to solve this issue...


MyInputinstead of a simpleinputtag? You may experience problems using another component instead of a simple HTML input when trying to use the same methods on it.exampleFileis not working on the input field which is what you want, but it is only a property on your custom component. What's the error message?