This is a simple upload component for Vuetify.
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vuetify-upload-component"></script>
...
<v-upload ...>
...
npm i vuetify-upload-component -s
Name <Type> | Description | Defaults | Notes |
---|---|---|---|
accept <String> |
Limit accepted file-types. | "*" | More information... |
multiple <Boolean> |
Set to accept multiple files. | false |
|
label <String> |
Header text. | "Attachments" |
<v-upload v-model="files"></v-upload>
<v-upload v-model="files" multiple></v-upload>
<v-upload v-model="files" accept="image/*"></v-upload>
<script>
import VUpload from "vuetify-upload-component"; // SSR and webpack
export default {
components: { VUpload },
data: () => ({
files: [] // An array of files received from the vuetify_upload_component
}),
methods: {
doSomethingWithFiles: () => {
if (this.files) {
this.files.forEach(file => {
const reader = new FileReader();
reader.onload = () => {
/*
* Do something with the file
*/
}
reader.readAsBinaryString(file);
}
}
}
}
}
</script>