Last active
May 27, 2022 18:38
-
-
Save lewiswalsh/e9af126b872e2f0c85802691095bb5a3 to your computer and use it in GitHub Desktop.
Upload on file change with Vue #vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="file" @change="previewFiles" ref="imagefile"> | |
methods: { | |
previewFiles(event) { | |
const fileToUpload = this.$refs.imagefile.files[0]; | |
const formData = new FormData(); | |
formData.append('fileToUpload', fileToUpload); | |
this.$http.post(`url/to/upload/script`, formData) | |
.then((res) => { | |
... | |
}) | |
.catch((err) => { ... }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment