Multi upload files with input

Viewed 26

How to multi upload files with tied input block? And store this in an array of objects enter image description here

1 Answers

This link may help you with the multiupload part, the only thing that you need to change is the addFile part. We just need to modify it a bit.

First of all, modify the state to be const state = reactive({files, fileName: ''}) and then the addFiles function to this:

const addFiles = (event) => {
  const file = event.target.files[0]
  const blob = file.slice(0, file.size, file.type);
  const newFile = new File([blob], state.fileName, {type: file.type});
  state.files.push(newFile)
}

If you want several inputs, then just modify the addFiles state.fileName to change it to an array and use state.fileNames[index] to use that name.

Related