How can we file input detect change on SAME file input in Vue Js
<input ref="imageUploader" type="file" @change="uploadImageFile">
We can add @click event and then clear the value of the file input
<template>
....
<input ref="imageUploader" type="file" accept=".jpg, .jpeg" @click="resetImageUploader" @change="uploadImageFile">
....
</template>
<script>
export default {
methods: {
resetImageUploader() {
this.$refs.imageUploader.value = '';
},
uploadImageFile() {
....
}
}
}
</script>
Same thing as @zubair's answer but for vue 3
and a bit more convenient:
<input type="file" @change="renderImage($event)" @click="$event.target.value=''">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With