My Html
<form method="post" action="/Upload" enctype="multipart/form-data">
<input type="file" name="files" multiple />
<input type="submit" value="Upload" class="btn" />
</form>
My Action
[HttpPost("/Upload")]
public async Task<IActionResult> Upload(){
var files = Request.Form.Files;
...
}
This work as expected when loaded directly from my Html View, but if i load the exactly same Html using React:
render(){
return(
<form method="post" action="/Upload" enctype="multipart/form-data">
<input type="file" name="files" multiple />
<input type="submit" value="Upload" className="btn" />
</form>
);
}
The post request works, but 'var files' is always a empty array.
Any idea whats wrong? Thank you all in advance
您应该使用ICollection<IFormFile> files
或IFormFile file
来处理asp.net核心中的文件。
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.