So I have this code for uploading images. If I upload a single image it works, but if I upload a list of images then request.FILES will be empty.
const createFormData = (photos, body = {}) => {
const data = new FormData();
if (photos.length > 1) {
const image_list = [];
for (var i = 1; i < photos.length; i++) {
const photo = photos[i];
image_list.push({
name: photo.fileName,
type: photo.type,
uri: Platform.OS === "ios" ? photo.uri.replace("file://", "") : photo.uri,
});
}
console.log(image_list)
data.append("images", image_list);
}
Object.keys(body).forEach((key) => {
data.append(key, body[key]);
});
return data;
};