System Information
- Strapi Version: 3.2.3
- Operating System: alpine3.12
- Database: postgres 13
- Node Version: node 12.19
- NPM Version: ?
- Yarn Version:
Hello, community,
I am trying to upload multiples files to an entry already created.
async addImagesToPost(images, postId) {
const bodyFormData = new FormData()
bodyFormData.append('ref', 'posts')
bodyFormData.append('refId', postId)
bodyFormData.append('field', 'images')
images.forEach(({ file }) => bodyFormData.append(`files.images`, file, file.name))
try {
// the client is an axios instance.
return await client.post('/upload', bodyFormData)
} catch (error) {
console.error("error while adding images to post", error)
return error.response
}
}
This is the code I am using and it doesn’t work. Even if instead of using files.images
I am using files[]
(which a standard look at here in the example) or 'files.' + index
it does not works.
If I am uploading a single file it works bodyFormData.append(
files, images[0].file, images[0].name)
They said how to upload multiples files at the same time as creating the entry but not when we want to add some files to an entry.
At the same time in the documentation there no mention of how to add a caption for instance on an image.
If somebody has the answer it will be great