我正在尝试上传excel文件。我收到错误:415(不支持的媒体类型)
我已经按照这个样本。
how to pass excel file to C# controller from angular 4 in Visual Studio 2017?
组件
public uploadFile() {
if (this.fileInput.files.length === 0) {
return; // maybe needs more checking
}
const formData = new FormData();
formData.append('file', this.fileInput.files[0]);
this.component.customExcelUploadProvider.UploadExcelFile(formData, () => { }, () => { });
}
服务:
UploadExcelFile(ExcelFile: FormData, success: () => void, failure: () => void) {
this.save(ExcelFile, success, failure);
}
控制器:
[HttpPost("CustomExcelFileUpload")]
public IActionResult CustomExcelFileUpload([FromBody] IFormFile excelFile)
{
return Ok();
}