title: Upload Image to URI using HttpClient
body: <p>I´m a newbie about http related things, so I am a little stacked.</p>
  
  <blockquote>
    <p>What I want is simple, I need to POST, upload a imaged to a server like this: <code>http://web.com/imageGalerry</code> . </p>
  </blockquote>
  
  <p>I think its not too much complicated <strong>but I dont know why I am no getting errors</strong> and so far now I´m not sure how to continue(because the image is not upload in fact), this is my code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public async Task&lt;object&gt; UpdateGalleryResources(IFormFile file, int idResouce)
          {
              byte[] data;
              string result = "";
              ByteArrayContent bytes;
              var urlToPost = "http://hello.uk/imagegallery/resources/" + 00+ "/" + file.FileName;
  
              MultipartFormDataContent multiForm = new MultipartFormDataContent();
  
              try
              {
                  using (var client = new HttpClient())
                  {
                      using (var br = new BinaryReader(file.OpenReadStream()))
                      {
                          data = br.ReadBytes((int)file.OpenReadStream().Length);
                      }
  
                      bytes = new ByteArrayContent(data);
                      multiForm.Add(bytes, "file", file.FileName);
                      //multiForm.Add(new StringContent("value1"), "key1");
                      //multiForm.Add(new StringContent("value2"), "key2");
  
  
                      var res = await client.PostAsync(urlToPost, multiForm);
                      return res;
                  }
              }
              catch (Exception e)
              {
                  throw new Exception(e.ToString());
              }
          }
  
  </code></pre>
  
  <p>This is the view:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form action="/Galley/UpdateGallery"  method="post" class="dropzone" id="myDropzone"&gt;
  
      &lt;input type="hidden" value="1" name="idResource" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>and the dropzone js I am using to handle the view:</p>
  
  <pre class="lang-js prettyprint-override"><code>document.addEventListener("DOMContentLoaded", function () {
  
      // access Dropzone here
      //dropzone.js detecta la version 'camelized' cuando el div tiene la clase dropzone
      Dropzone.options.myDropzone = {
          addRemoveLinks: true,
          //autoProcessQueue: false,
  .....
         }
  </code></pre>
  
  <blockquote>
    <p>And this is the error code I get from <code>return res</code></p>
  </blockquote>
  
  <pre><code>  {StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers:
  {
    Server: Microsoft-IIS/8.5
    X-Powered-By: ASP.NET
    Date: Thu, 23 Apr 2020 08:22:52 GMT
    Content-Type: text/html
    Content-Length: 1282
  }}
  </code></pre>
  
  <p>This is what I check in debug mode, everything I think looks right:
  <a href="https://i.stack.imgur.com/tDsf3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tDsf3.png" alt="enter image description here"></a></p>
  
  <p>Can you help me about what I am doing wrong??
  Thank you.</p>