Team member and I have been working on getting a multiple file upload component working in react with a asp.net back-end. Team member wrote the back-end, so I do have limited knowledge of exactly what the api is doing, but when we send a request using Postman, the file does arrive and is visible in the model debugger.
I've tried various ways of sending the files from my React front-end, including sending as a direct copy of the state, sending as an array with additional information, and sending as a set of independent files, as seen here.
Yes, the form is using
<form encType="multipart/form-data"/>
but the file upload itself is obfuscated behind a DropZone component that I designed.
Team member and I are both fairly new to React and are getting frustrated with this detail.
API Call:
const data = new FormData(form);
for(var i=0; i <this.state.files.length; i++){
filesArray.push('files'+ i, this.state.files.item(i));
}
data.append("files", filesArray);
fetch('http://localhost:5824/api/Claim', {
method: 'POST',
body: data,
});
relevant portion of the DropZone in the form:
<input ref={this.fileInputRef} className="dropInput" type="file" multiple onChange={this.onFilesAdded}/>
<span>Upload Files</span>