ASP.NET Core - Upload And Download
上传
[HttpPost] public async Task<IActionResult> Import(IFormCollection formData) { string sWebRootFolder = _hostingEnvironment.WebRootPath; string sFileName = $"{Guid.NewGuid()}"; FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName)); var excelfile = formData.Files[0]; try { using (FileStream fs = new FileStream(file.ToString(), FileMode.Create)) { excelfile.CopyTo(fs); fs.Flush(); }return Ok(Success()); } catch (Exception ex) { return Ok(Failed()); } }