public class uploadImage { [FileTypes("jpg,jpeg,png")] public HttpPostedFileBase File128 { 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 st = (_value as HttpPostedFileBase).FileName; var fileExt = System.IO.Path.GetExtension((_value as HttpPostedFileBase).FileName).Substring(1); return mTypes.Contains(fileExt, StringComparer.OrdinalIgnoreCase); } }
public class uploadImage { [FileTypes("jpg,jpeg,png")] 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; } //how can check items of IEnumerable<HttpPostedFileBase>???? } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)