[Vuejs]-Vue Axios – with bootstrapVue and vuex, still problem to upload file and text?

1👍

When you want to upload an image you have to set the content type and create FormData, like this:

    let data = new FormData();

    for (var i = 0; i < files.length; i++) {
        let file = files.item(i);
        data.append('images[' + i + ']', file, file.name);
    }

    const config = {
        headers: { 'content-type': 'multipart/form-data' }
    }

    return axios.post('/api/images', data, config)

Leave a comment