<template>
<div class="form-avatar">
<label>
<img src="#" alt="Аватар">
<input type="file" v-show="false" @change="fileInput($event)">
</label>
</div>
</template>
<script>
export default {
name: "create",
methods: {
fileInput(event) {
console.log(event.target.files[0])
}
}
}
</script>
const formData = new FormData()
this.selectedFile = event.target.files[0]
formData.append('myFile', this.selectedFile, this.selectedFile.name)
this.$http.post('http://127.0.0.1:8000/upload', formData).then(response => {
console.log('onUpload file ', formData.length ); // 1
status = response.status;
console.log('status --> ', status)
// get status text
response.statusText;
}, response => {
// error callback
console.log('errror ')
});