I am trying to upload mutliple files through axios with a description field.
i submit multiple files it's working but the problem is that when i submit array of files then in axios when i append formdata the list of files is submitting as
[object FileList]
and i can't access my file to send as binary.
here is my Interface for Submitting file
export interface attachments{
id?:number;
archiveid:number;
file:Blob[] | undefined;
attachmentDetail:attachmentDetail[];
}
export interface attachmentDetail{
files:Blob;
attachmentDetail:string;
}
this is my agent function that i submit my attachments with axios
<pre>addAttachments: (data: attachments) => {
const formData: FormData = new FormData()
for (let i = 0; i < data.attachmentDetail.length; i++) {
const file=[data.attachmentDetail[i].files];
formData.append(`Attachment[${i}]`,file[i]);
formData.append(`Detail[${i}]`,
data.attachmentDetail[i].attachmentDetail);
formData.append('ArchiveId',data.archiveid!.toString());
return axios.post<attachments, any>('/AttachmentFile', formData, {
headers: { 'Content-type': 'multipart/form-data' },
});
},
so if any solution is please kindly suggest me i am stack in it for many days
What I have tried:
i have tried this all code is in this Link of sand box
my work Link