const fd = new FormData();
fd.append('image', this.state.selectedFile, this.state.selectedFile.name);
const postData = {
method: 'POST',
credentials: 'include',
body: fd
}
//this correctly shows the image object and name:
console.log('selected image file name: ', this.state.selectedFile.name);
console.log('select image: ', this.state.selectedFile);
axios({
method: 'post',
url: `/api/gameStats/profileImage/${this.props.profileId}/files/upload`,
postData
})
.then(function (response) {
console.log('then: ', response);
})
.catch(function (response) {
console.log('catch: ', response);
});
[HttpPost("upload")]
public virtual async Task<IActionResult> PostMulti(Int64 parentId, ICollection<IFormFile> fileData)
{
'fileData is always empty... :(
TParent parent;
using (var tran = Session.BeginTransaction()) {
parent = Repository.GetParent(parentId);
if (!Security.CanCreate(CurrentUser, parent, null))
return StatusCode(HttpStatusCode.Forbidden);
tran.Rollback();
}
foreach (var file in fileData) {
await SaveFile(file, parent);
}
return Created("", Map(Repository.Get(parentId)));
}