I have a problem with a file reader, it load the file never the fist time, and it's like a queue. I mean: it start from the second time I select a file but it upload the first.
Can I solve this?
Here the code.
<v-text-field
v-if="switch1"
label="Upload Fattura"
@click='onPickFile'
v-model='fatturaFileName'
prepend-icon="mdi-paperclip"
></v-text-field>
<input
type="file"
style="display: none"
ref="fileInput"
accept="text/xml"
@change="onFilePicked"
>
onPickFile () {
this.$refs.fileInput.click();
}`
onFilePicked (event) {
if (event) event.preventDefault();
var files = event.target.files[0];
if (files !== undefined) {
this.fatturaFileName = files.name;
// If valid, continue
const fr = new FileReader();
fr.readAsText(files);
fr.addEventListener('load', () => {
this.fatturaUpload = fr.result;
});
} else {
this.fatturaFileName = ''
this.fatturaFileObject = null
}
console.log(this.fatturaUpload);
}