does anybody knows how to reset my input type="file". I'm been using the $this->reset()
to clear the property of the input type="file"
.
$this->reset(['type', 'name', 'institution', 'year', 'certification']);
If you don't need to use id
for any other purposes you can render the input like this:
<input type="file" id="{{ rand() }}" >
Instead of using rand()
you can also use some kind of counter or any other value that will change on every render. Different id
will force livewire to completely replace the element with new one, thus empty. Just setting value=""
won't help as input type="file"
is immutable. This solution is taken from here
Here is a solution I found in TALL Stack Tips to remove filename from input field after uploading via Livewire. https://talltips.novate.co.uk/livewire/livewire-file-uploads-using-s3#removing-filename-from-input-field-after-upload
The solution involves implementing a counter to regulate the input file id
document.getElementById("uploadedfile").value = "";
in pure js script – bhucho