2
I need to receive a file json
for input type file
and read the contents of this file on the front without having to make a request to the server.
<input type="file" id="file" ref="file" v-on:change="handleFileUpload()" />
handleFileUpload() {
var reader = new FileReader();
var file = this.$refs.file.files[0];
reader.onload = function() {
console.log(reader.result)
};
reader.readAsText(file)
},
I can print the file in the console but not put it in a variable to use inside the code.