In vue.js to send a file that it came in $_FILES?

Hello.
How do I send a file to the data were not included in php://input and was accessible directly from $_FILES?
Or $_POST Request when sending data, they are not available in the $_POST array, and yet again, in php://input
Please tell me, how am I supposed to get around?

Now the code for sending files like this:
the <script>
 new Vue({
 el: '#app',
 data: {
 files: []
},
 methods: {
 onFileChange: function(e) {
 var files = e.target.files || e.dataTransfer.files;
 if (!files.length)
return;
this.createImage(files[0]);
},
 createImage: function(file) {
 var reader = new FileReader();
 var vm = this;
 reader.onload = function(e) {
 vm.image = e.target.result;
};
reader.readAsDataURL(file);
},
 upload: function(){
 axios.post('/file', {image: this.image}})
 .then(function(res) {
console.log(res);
});
}
}
})
</script>
June 14th 19 at 20:53
1 answer
June 14th 19 at 20:55
Solution
use FormData

Something like that happens:

let data = new FormData();
data.append('file', thi.image);

axios.post('/file', data)
 .then(function(res) {
console.log(res);
 });
Thank you:) - Golda commented on June 14th 19 at 20:58

Find more questions by tags PHPVue.js