很简单的文件上传,在swagger里运行提示错误:
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
#pragma warning disable 1591
namespace WebApplication2.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class FileController : ControllerBase
{
/// <summary>
/// 文件上传
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
[HttpPost]
public bool Upload(IFormFile file)
{
var fileName = file.FileName;
var path = "D:/Test/";
using (var stream = new FileStream(path + fileName, FileMode.Create))
{
file.CopyTo(stream);
}
return true;
}
}
}
有大神能看出是什么问题吗?