I need to send an array of arrays in a multipart form.
let currentObj = this;
let formData = new FormData();
for (var i = 0; i < this.mediaData.length; i++) {
let file = this.mediaData[i];
console.log(file, "file");
formData.append('medias[' + i + ']', , file.file, file.original_file_name, file.function_name);
}
for (var i = 0; i < this.mud_table.name.length; i++) {
let mud = this.mud_table.name[i];
formData.append('mud_table[' + i + ']', mud);
}
formData.append('mud_map_status', this.mud.status);
formData.append('mud_map_id', this.mud.id)
formData.append('surveyReportID', this.survey_reporting_id);
with this code i can only send the files file property from the mediasData array into a controller.
mediasData:[function_name:mud_pdf1; original_file_name: recipt_pdf.pdf; file:{File},
function_name:mud_pdf2; original_file_name: recipt_pdf.pdf; file:{File},
function_name:mud_pdf3; original_file_name: recipt_pdf.pdf; file:{File}]
is in this format and in the backend I am only getting medias:[file:{File}] format in the request.
i also need to send the "original_file_name" and "function_name" properties too. of course i could break the array into 3 parts and append them individually, but is there any way to send all there properties of each mediasData array index into formdata array respective index?
mediasNamesbit looks very odd. Could you please explain what data you want to send?