forked from VahidN/DNTCommon.Web.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserFileViewModel.cs
22 lines (19 loc) · 925 Bytes
/
UserFileViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
namespace DNTCommon.Web.Core.TestWebApp.Models;
public class UserFileViewModel
{
[Required(ErrorMessage = "Please select a file.")]
//`FileExtensions` needs to be applied to a string property. It doesn't work on IFormFile properties, and definitely not on IEnumerable<IFormFile> properties.
//[FileExtensions(Extensions = ".png,.jpg,.jpeg,.gif", ErrorMessage = "Please upload an image file.")]
[UploadFileExtensions(".png,.jpg,.jpeg,.gif", ErrorMessage = "Please upload an image file.")]
[DataType(DataType.Upload)]
public IFormFile Photo { get; set; }
}
public class GeneralFileViewModel
{
[Required(ErrorMessage = "Please select a file.")]
[AllowUploadSafeFiles(ErrorMessage = "You are not allowed to upload these types of files.")]
[DataType(DataType.Upload)]
public IFormFile UserFile { get; set; }
}