title: Sending file contents from php curl (using post) to c# webapi
body: <p>I have to transfer a file object from php to c# webapi.
  Somehow, in c#, the file contents are coming as Null.
  This is the partial PHP code after taking out the other stuff</p>
  
  <pre><code> &lt;?php
   $fileContents =  file_get_contents($_FILES['fileToUpload']['tmp_name']); 
  
      $uploadFile = new UploadFile();  //custom object
      $uploadFile-&gt;fileName = "test";  //string
      $uploadFile-&gt;fileContent = $fileContents; //string
  
  
      $data_string=json_encode($uploadFile);
  
      $url="http://localhost:62672/api/uploadfile";
  
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
      curl_setopt($ch,CURLOPT_VERBOSE, TRUE);
      //curl_setopt($ch, CURLOPT_PORT, 801);
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  
      curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
  
      curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array(
              'Content-Type: application/json',
  
      ));
  
  ?&gt;
  </code></pre>
  
  <p>And here is the c# controller code &amp; model code</p>
  
  <pre><code> public class CrmUploadFileModel
      {
          public string fileName { get; set; }
          public byte[] fileContent { get; set; }
  
  
      }
  public class UploadFileController : BaseController
      {
  
          public IHttpActionResult Post([FromBody]CrmUploadFileModel value)
          {
  // here .. i find that the value.fileContent is null. 
  }
  </code></pre>
  
  <p>Just started learning .NET and hence dont know if anything is wrong in the .NET code.</p>
  
  <p>Using the same PHP code, i am able to send succesfuly the file contents to a .NET webservice, which is a separate application.</p>
  
  <p>Thanks in advance.
  Aman</p>