following code i am able to validate when i select a single image.But how can i change this validation when i want to upload multiple images
[Required]
public BrowsedFile FileToUpload { get; set; }
//how i can change below code when i have list of files
[Required(ErrorMessage = "files should be mime types")]
public string FileContentType =>ContentTypes.TryConvertFromFileExtension(FileToUpload?.FileExtension, FileToUpload?.File.ContentType ?? string.Empty);
following list i will be using for multiple image store
[Required]
public IReadOnlyList? ListFiles{get;set:)
Sujeet RamanPosted Jan 18, 2023, 10:30 AM
How can i validate using IValidator object? I need to check file name is empty or not? and the content type and the list is empty or not
need to give validation for
not for list now.Then i need to use
Anupam MaitiPosted Jan 18, 2023, 9:00 AM
We can use the
System.IO.Fileclass to validate the MIME type of multiple selected files.Naimish MakwanaPosted Jan 18, 2023, 7:25 AM
You can create your Custom attribute.
Then you can use it on property.
Source : https://stackoverflow.com/questions/62727427/how-to-validate-uploaded-files-in-asp-net-mvc
Thanks.