string filepath = "";
if (Request.Files.Count > 0)
{
var imageFile = Request.Files[0];
filepath = $"/Upload/ScoreApply/{DateTime.Now.ToString("yyyyMMdd")}/{Guid.NewGuid().ToString("N")}{Path.GetExtension(imageFile.FileName)}";
string filename = Server.MapPath(filepath);
if (!Directory.Exists(Path.GetDirectoryName(filename)))
{
Directory.CreateDirectory(Path.GetDirectoryName(filename));
}
imageFile.SaveAs(filename);
}
MVC 后台接前台上传图
最新推荐文章于 2021-02-07 12:34:13 发布