且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过Axios将文件发送到Laravel

更新时间:2021-11-04 06:45:20

您必须创建一个FormData对象并附加图像文件.

You have to create a FormData object and append the image file.

methods: {
  'successUpload': function (file) {

    let data = new FormData();
    data.append('file', document.getElementById('file').files[0]);

    axios.post('/Upload/File',data).then(function (response) {
        console.log(response.data);
    });
  }
}

例如此处.

让我知道是否可行.