1👍
✅
I assume your backend accept multipart/form-data
and using axios
<input type="file" @change="onFileChange" />
export default {
methods: {
onFileChange(e) {
const formData = new FormData();
formData.append("file", e.target.files[0]);
axios
.post("/upload", formData)
.then(() => {
console.log("SUCCESS");
})
.catch(() => {
console.log("FAILED");
});
},
},
}
Source:stackexchange.com