Next.js Discord

Discord Forum

formData with file

Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Open in Discord
Australian Freshwater CrocodileOP
please i need help, send file to formData

const formData = new FormData(); Object.entries(values).forEach(([key, value]) => { if (Array.isArray(value)) { const galleryTourArray: any = []; value.forEach((subVal) => { galleryTourArray.push({ titleGallery: subVal.titleGallery, imageGallery: new Blob([subVal.imageGallery as File], { type: subVal?.imageGallery?.type, }), }); }); formData.append(key, JSON.stringify(galleryTourArray)); } else if (value instanceof Date) { formData.append(key, value.toString()); } else { formData.append(key, value); } });

0 Replies