title: MVC 4 RegisterModel include Profile Image
body: <p>Within my MVC 4 application when a user registers I'm looking to give them the option to select an image and upload that at the same time as registering - I was just looking at some guidance as to how to do this.</p>
  
  <p>Here is my MVC Model for registering - I've added HttpPostedFileBase to hold the file being posted along with the username and password for new account being registered:</p>
  
  <pre><code>public class RegisterModel
  {
      [Required]
      [Display(Name = "User name")]
      public string UserName { get; set; }
  
      [Required]
      [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
      [DataType(DataType.Password)]
      [Display(Name = "Password")]
      public string Password { get; set; }
  
      [DataType(DataType.Password)]
      [Display(Name = "Confirm password")]
      [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
      public string ConfirmPassword { get; set; }
  
      public HttpPostedFileBase File { get; set; }
  
  }
  </code></pre>
  
  <p>The registration View includes the following input html:</p>
  
  <pre><code>&lt;input id="register-avatar"  type="file" name="file" /&gt;
  </code></pre>
  
  <p>However when I register, the value for the file is always null...</p>
  
  <p>UPDATE 04-11-2013</p>
  
  <p>I finally created a post which doesn't seem to be covered on how to include a profile image upload with the generic RegisterModel within the MVC 4 Template.  You can find it here - <a href="https://stackoverflow.com/questions/19776346/mvc-4-add-profile-image-to-registermodel/19776347#19776347">MVC 4 Add Profile Image to RegisterModel</a></p>
  
  <p>UPDATE</p>
  
  <p>The problem as mentioned in the comment below is that I did not have the enctype set. For more information have a look <a href="https://stackoverflow.com/questions/4526273/what-does-enctype-multipart-form-data-mean">here</a></p>