title: post file to third party API using curl
body: <p>I am using below code to post a file to third party API - </p>
  
  <pre><code>$post = array('userName' =&gt; 'testabc','password'=&gt;'testabc','FILE1'=&gt;'abc.csv','cn'=&gt;'10215');
          $fp = fopen("orders/abc.csv", 'r');
  
          $ch = curl_init("https://differentdomain.com/abc.cgi");
  
          curl_setopt($ch, CURLOPT_USERPWD, "myuser:mypwd");            
          curl_setopt($ch, CURLOPT_UPLOAD, 1);
          curl_setopt($ch, CURLOPT_TIMEOUT, 86400); 
          curl_setopt($ch, CURLOPT_INFILE, $fp);
          curl_setopt($ch, CURLOPT_NOPROGRESS, false);
          curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'CURL_callback');
          curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
          curl_setopt($ch, CURLOPT_INFILESIZE, filesize("orders/abc.csv"));
          curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
          curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
          $suc = curl_exec ($ch);
  
          echo "==&gt;".curl_error($ch);
          echo "--&gt;".$suc; die;
  </code></pre>
  
  <p>It returns with 500 Internal Server Error. Not sure whether the way I am posting parameters are right or wrong.</p>
  
  <p>Any help appreciated.</p>
  
  <p>Thanks.</p>