vue.jsvuejs2onchangevuetify.js

VueJS: Input file selection event not firing upon selecting the same file


How can we file input detect change on SAME file input in Vue Js

<input ref="imageUploader" type="file" @change="uploadImageFile">


Solution

  • 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>