Axiosでファイルをアップロードする方法を書きます。
コード
template
<input type="file" v-on:change="select_file" /> <button @click="send">送信</button>
Script
data(){ return { file:null } }, methods:{ select_file:function(e){ this.file = e.target.files[0] }, send:function(){ let params = new FormData(); params.append("image",this.file) this.$axios.$post("url",params) .then(res=>{ alert("送信完了") }) } }ビスケットを送る
0
コメント