title: How to Convert File Image to Byte[] ReactJS?
body: <p>I want to send image to api end point and end point accept byte[] how can i handle this.
  My code is:
  ReactJS function on upload button click:</p>
  <pre><code>    let onClickHandler = () =&gt; {
          let data = new FormData()
          data.append('file', image);
  
          axios.post(&quot;/Contact/ContactForm/&quot;,  {
              
              AttachedImage: data
  
          }, {
              
                  headers: {
                      'Content-Type': 'multipart/form-data',
                      'X-Requested-With': 'XMLHttpRequest',
                  }
              // receive two parameter endpoint url ,form data
          })
              .then(res =&gt; { // then print response status
                  console.log('binary Response......',res.statusText)
              });
  }
  </code></pre>
  <p>and my endpoint controller method:</p>
  <pre><code>[HttpPost]
          public async Task&lt;IActionResult&gt; ContactForm([FromBody] Contact model)
          {
              try
              {
                  model.CreationDate = DateTime.Now;
                  await _contact.ContactForm(model);
                  return Ok(&quot;Submitted Successfully&quot;);
              }
              catch (Exception ex) { return this.BadRequest(&quot;Not Submitted Successfully&quot; + ex.ToString()); }
          }
  </code></pre>
  <p>and finally Model.cs Class</p>
  <pre><code>public byte[] AttachedImage { set; get; }
  </code></pre>