How to send a post request after el-upload uploads a picture in elementUi

upload pictures with el-upload in elementUi, and then send the picture data and form data together to the post request to the backend. The form data can be obtained by the backend, but the image data has not been available. What is the reason?

<div class="item-pic-bg">
    <img class="bgImg" :src="src" alt="">
        <el-upload
            class="upload"
            accept="image/*"
            :show-file-list="false"
            action="/upload/uploadFile"
            :on-success="handleSuccess">
        <el-button type="primary" @click="refeshLoad()" class="refesh btnNoBorder button b2">
        <i class="iconfont icon-shangchuan"></i> 
        </el-button>
        </el-upload>
</div>
//
            handleSuccess: function (response, file, fileList) {
                this.src = file.url;
                this.formData.files.push(file.raw);
            },
            
               //
            saveIt: function () {
                let formData = new FormData();
                formData.append("files", this.formData.files);
                //post         
                saveSlideShow(formData).then((res) => {
                })
            },
Mar.02,2021

this article can solve the problem: Link description


paste the general code to help you check

Menu