I have a problem, I need to pass model as first a parameter, and as the second parameter, I need to pass a file
Adding a file to a form:
const formDate = new FormData();
formDate.append("File", this.file);
Sending data from angular:
this.dataService.createRestaurant(this.restaurant, formDate)
.subscribe((data: Restaurant) => this.loadProducts(data))
Data sending service:
createRestaurant(model: Restaurant, form: FormData){
const headers = new HttpHeaders().append("Content-Disposition", "multipart/form-data")
return this.http.post(this.url, {model, form}, {headers: headers});
}
Controller in Asp.net core:
public IActionResult Post(Restaurant restaurant, IFormFile File)
{
code...
}
I tried to solve this problem for two days, the model is transferred normally, but the file is always null