I am trying to send a file and other data to an Asp-Core-BackEnd.
In the backendController, I read the file like:
IFormFile file = HttpContext.Request.Form.Files.First(); //don't work
HttpContext.Request.Form.TryGetValue("id", out id) //works
Works for other Clients. But I want use the Api with JS.
My js-code (react) looks like this:
const formData = new FormData();
formData.append('id', 123);
formData.append('files', files); //don't work
const config = {
headers: {
'content-type': 'multipart/form-data; charset=utf-8; boundary="------";'
}
}
await axios.post(url, formData, config);
but Form.Files is an empty Array
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.