title: How to execute this curl command in PHP?
body: <p>Executing this curl command from terminal is working and i am getting back my results.</p>
  
  <pre><code>curl -F "file=@/var/www/html/uploads/fb5bc34e1f0f03c759e92010f6a1a302_modified.csv" http://10.0.0.106:8089/uploadAndMatch/ -o ~/out.txt
  </code></pre>
  
  <p>But when trying it from PHP with the following code I am getting 400 httpcode:</p>
  
  <pre><code>    $request = curl_init('http://10.0.0.106:8089/uploadAndMatch/');
      curl_setopt($request, CURLOPT_POST, true);
      curl_setopt($request,
      CURLOPT_POSTFIELDS,
      array(
          'file' =&gt; '@/var/www/html/uploads/fb5bc34e1f0f03c759e92010f6a1a302_modified.csv'
      ));
      curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
      echo curl_exec($request);
      $httpcode = curl_getinfo($request, CURLINFO_HTTP_CODE);
      echo $httpcode;
      curl_close($request);
  </code></pre>
  
  <p>I also tried to add a header :</p>
  
  <pre><code>$header = array('Content-Type: multipart/form-data');
  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  curl_setopt($ch, CURLOPT_POST, 1);
  </code></pre>
  
  <p>But it's still the same error! <code>400 bad request</code>
  Any thoughts?</p>
  
  <p>It wasn't a debugging problem, it's because the <a href="https://wiki.php.net/rfc/curl-file-upload" rel="nofollow noreferrer">changes</a> in php5.5+</p>