📜  验证文件上传 asp.net core mvc - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:58.256000             🧑  作者: Mango

代码示例1
public class UserViewModel
{
        [Required(ErrorMessage = "Please select a file.")]
        [DataType(DataType.Upload)]
        [MaxFileSize(5* 1024 * 1024)]
        [AllowedExtensions(new string[] { ".jpg", ".png" })]
        public IFormFile Photo { get; set; }
 }