0

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

1
  • The file input name could be files[] and the text file_texts[]. One array index in files will then match with an array index of file_texts Commented Sep 6, 2022 at 11:54

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.