Javascript 在laravel 5.3中使用axios上载图像文件
我是axios的新手,所以我需要帮助。我正在使用laravel 5.3中的axios上传图像文件,但axios没有将图像文件传递到服务器。这是我的axios代码Javascript 在laravel 5.3中使用axios上载图像文件,javascript,php,laravel-5.3,axios,Javascript,Php,Laravel 5.3,Axios,我是axios的新手,所以我需要帮助。我正在使用laravel 5.3中的axios上传图像文件,但axios没有将图像文件传递到服务器。这是我的axios代码 formSubmit: function(){ axios.post('/postdata',this.$data,) .then(response => alert('Success')) .catch(error => this.errors.record
formSubmit: function(){
axios.post('/postdata',this.$data,)
.then(response => alert('Success'))
.catch(error => this.errors.record(error.response.data));
},
除了文件本身之外,将提交整个表单数据 我认为在处理ajax文件上传时应该使用
FormData()
对象
let formData = new FormData();
this.form.append(ele.target.name, files[0])
axios.post('/postdata', formData)
.then(response => alert('Success'))
.catch(error => this.errors.record(error.response.data));