Before uploading an image, I am trying to re-place the current filename of the User with the chosen file from the input through an onchange method.
With the current setup below, the img changes into a blank space and hides the src, without throwing an error.
<img id="img" :src="filename" class="image">
<input type="file" name="file" ref="file" accept="image/*" @change="onChange">
props: ['user'],
data() {
return {
filename: this.user.url
}
},
methods: {
onChange(file) {
this.filename = this.$refs.file.file
}
},
If I try this.filename = this.$refs.file.files img turns into src="[object FileList]"
Also not working: this.filename = file.src
Any idea what I am missing?