mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-02-02 13:07:34 +00:00
Bagels.
This commit is contained in:
parent
d5e460acf2
commit
be641700f8
2 changed files with 8 additions and 4 deletions
|
@ -43,6 +43,8 @@ namespace Project_Unite.Controllers
|
|||
string[] allowedTypes = new[] { ".png", ".jpg", ".bmp", ".jpeg", ".gif" };
|
||||
|
||||
bool containsAllowedType = false;
|
||||
if (model.Image != null)
|
||||
{
|
||||
foreach (var ending in allowedTypes)
|
||||
{
|
||||
if (model.Image.FileName.EndsWith(ending))
|
||||
|
@ -51,6 +53,7 @@ namespace Project_Unite.Controllers
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (containsAllowedType == false)
|
||||
ModelState.AddModelError("UploadImageViewModel", new Exception("File type not allowed."));
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Project_Unite.Models
|
|||
public class UploadImageViewModel
|
||||
{
|
||||
[Required(ErrorMessage = "Please select an image to upload.")]
|
||||
[DataType(DataType.Upload)]
|
||||
public HttpPostedFileBase Image { get; set; }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue