Answer the question
In order to leave comments, you need to log in
How to send a file in vue.js so that it gets into $_FILES?
Hello.
How can I send a file so that the data does not go to php://input, but is available directly from $_FILES?
Or by the same $_POST Request, when I send the data, they are not available in the $_POST array, but again, in php://input
Please tell me how can I get around this?
<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>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question