[Vuejs]-Vue.js how to upload image and AFTER THAT run custom method

1👍

You can add a callback to the input to listen for file changes.

First edit the html:

<input type="file" class="d-none" id="load-category-image" v-on:change="handleFileSelected">

Then you can handle what happens with the files selected in your component:

    methods: {
        loadImage($e){
            //...
        },
        handleFileSelected(event) {
            const files = document.getElementById('load-category-image').files;
            console.log(files);
        }
    },

Leave a comment