title: How to do server side validation for byte type image file in C#
body: <p>How to make server side validation for byte type. I have to upload image file and for that I have used byte. But when i do not upload image, it throws error which is normal behavior but the problem arises when I supply image and upload and submit it, the message still appears. How to remove that message after image upload.</p>
  
  <p>.Class file</p>
  
  <pre><code>  public class EmailModel
    {        
      [Display(Name = "Attach photo")]
      [Required(ErrorMessage = "Please upload image")]
      public byte[] Photo { get; set; }
     }
  </code></pre>
  
  <p>index file</p>
  
  <pre><code>&lt;input type="file" name="ImageData" id="ImageData" onchange="fileCheck(this);" /&gt;
  @Html.ValidationMessageFor(m =&gt; m.Photo, "", new { @class = "text-danger" })
  </code></pre>
  
  <p>After submit the form, I have used this code to clear that validation error message in controller section</p>
  
  <pre><code>Array.Clear(emailvalues.Photo, 0,emailvalues.Photo.Length);
  </code></pre>