diff options
| author | Michael <[email protected]> | 2017-03-25 16:56:05 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-03-25 16:56:05 -0400 |
| commit | be641700f8f0e549861f0223b42674e7c83e0bc7 (patch) | |
| tree | ec259d26b61fdda4b2d888c8c6d2503f297cf88b | |
| parent | d5e460acf2f9696fcecfa63d91f6b03064b1557f (diff) | |
| download | project-unite-be641700f8f0e549861f0223b42674e7c83e0bc7.tar.gz project-unite-be641700f8f0e549861f0223b42674e7c83e0bc7.tar.bz2 project-unite-be641700f8f0e549861f0223b42674e7c83e0bc7.zip | |
Bagels.
| -rw-r--r-- | Project-Unite/Controllers/ManageController.cs | 11 | ||||
| -rw-r--r-- | Project-Unite/Models/IdentityModels.cs | 1 |
2 files changed, 8 insertions, 4 deletions
diff --git a/Project-Unite/Controllers/ManageController.cs b/Project-Unite/Controllers/ManageController.cs index 5f68eea..99f41c9 100644 --- a/Project-Unite/Controllers/ManageController.cs +++ b/Project-Unite/Controllers/ManageController.cs @@ -43,12 +43,15 @@ namespace Project_Unite.Controllers string[] allowedTypes = new[] { ".png", ".jpg", ".bmp", ".jpeg", ".gif" }; bool containsAllowedType = false; - foreach(var ending in allowedTypes) + if (model.Image != null) { - if (model.Image.FileName.EndsWith(ending)) + foreach (var ending in allowedTypes) { - containsAllowedType = true; - break; + if (model.Image.FileName.EndsWith(ending)) + { + containsAllowedType = true; + break; + } } } if (containsAllowedType == false) diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs index c08e4c7..187bad3 100644 --- a/Project-Unite/Models/IdentityModels.cs +++ b/Project-Unite/Models/IdentityModels.cs @@ -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; } } |
