public class uploadImageMahsolat { [FileTypes("jpg,jpeg,png")] [Required(ErrorMessage = "its Required.")] public HttpPostedFileBase Fileimg { get; set; } [FileTypes("jpg,jpeg,png")] [Required(ErrorMessage = "its Required .")] public ICollection<HttpPostedFileBase> FileUpload900 { get; set; } }
public class FileTypesAttribute : ValidationAttribute { private readonly List<string> mTypes; public FileTypesAttribute(string _types) { mTypes = _types.Split(',').ToList(); } public override bool IsValid(object _value) { if (_value == null) { return true; } var fileExt = System.IO.Path.GetExtension((_value as HttpPostedFileBase).FileName).Substring(1); return mTypes.Contains(fileExt, StringComparer.OrdinalIgnoreCase); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)