私は斧に新しいので、私は助けが必要です。私はlaravel 5.3でAxiosを使って画像ファイルをアップロードしていますが、Axiosは画像ファイルをサーバに渡していません。ここに私の斧コードです。
formSubmit: function(){
axios.post("/postdata",this.$data,)
.then(response => alert("Success"))
.catch(error => this.errors.record(error.response.data));
},
ファイル自体を除いてフォームデータ全体が提出されます。
回答:
回答№1は0まあ、私はあなたが使うべきだと思う FormData()
オブジェクトは、ajaxファイルのアップロードを扱うとき。
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));