Asp.Net Core WebApi 和Asp.Net WebApi上传文件
1 public class UpLoadController : ControllerBase 2 { 3 private readonly IHostingEnvironment _hostingEnvironment; 4 5 public UpLoadController(IHostingEnvironment hostingEnvironment) 6 { 7 _hostingEnvironment = hostingEnvironment; 8 } 9 [HttpPost] 10 public async Task< string > Post([FromForm] IFormCollection formCollection) 11 { 12 string result = "" ; 13 string webRootPath = _hostingEnvironment.WebRootPath; 14 string contentRootPath = _hostingEnvironment.ContentRootPath; 15 16 FormFileCollection filelist = (FormFileCollection)formCollection.Files; 17 18 foreach (IFormFile file in filelist) 19