title: using curl in php for real post request to remote server
body: <p>I have to automate uploading values to a remote server by php script.</p>
  
  <p>The interface accepts only POST variables - NO GET variables.</p>
  
  <p>Interface documentation (for form field names) looks like:</p>
  
  <pre><code>iegUsername: your username
  iegPassword: your password
  iegImportFile: The UTF-8 encoded plain text import file. The file data may optionally be zipped.
  </code></pre>
  
  <p>This means i have to POST TWO VARIABLES and ONE FILE.
  I'm new in Curl therefore i started in PHP with this:</p>
  
  <pre><code>// create curl resource
  $request = curl_init();
  
  // Array with the fields names and values
  $postData = array(
  'iegUsername' =&gt; 'myusername',
  'iegPassword'  =&gt; 'mypassword',
  'submit'    =&gt; 'ok'
  );
  //add file support with: 'file' =&gt; '@' . realpath('example.txt')
  
  // set timeout if remote server is down
  curl_setopt($request, CURLOPT_CONNECTTIMEOUT, 30);
  
  // set remote target url
  curl_setopt($request, CURLOPT_URL, ""); //for testing post on current page
  
  //Enable the post response.
  //curl_setopt($request, CURLOPT_POST, true);
  curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");
  
  $headers = ['Content-Type: multipart/form-data'];
  curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
  
  //The data to transfer with the response.
  curl_setopt($request, CURLOPT_POSTFIELDS, $postData);
  
  //return the transfer as a string
  curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
  
  // disable verification
  curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($request, CURLOPT_SSL_VERIFYHOST, false);
  </code></pre>
  
  <p>Actually i don't have added file support. </p>
  
  <p><strong>My Problem</strong></p>
  
  <p>In Browser dev tools i cannot see any POST only GET responses.</p>
  
  <p>I need a real POST with data in it not a urled GET one...</p>
  
  <p>Hopefully someone can give help.</p>