title: PHP cURL POST request - File corrupted during upload
body: <p>I'm trying to upload files to Redmine using the following PHP code.</p>
  
  <pre><code>$curl = curl_init();
  
  curl_setopt($curl, CURLOPT_URL, $url)
  curl_setopt($curl, CURLOPT_HTTPHEADER, array(
      'Content-Type: application/octet-stream',
      'X-Redmine-API-Key: ' . $apiKey));
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_BINARYTRANSFER, TRUE);
  
  $data = array('file' =&gt; '@' . $filePath);
  
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  curl_setopt($curl, CURLOPT_POST, 1);
  
  $token = curl_exec($curl);
  </code></pre>
  
  <p>This request returns a valid upload token but the file is corrupted during upload. Trying to upload, for example, an empty .txt file results in an uploaded overwritten .txt file now containing the following lines.</p>
  
  <blockquote>
    <p>------------------------------dde946a683ac</p>
    
    <p>Content-Disposition: form-data; name="file";
    filename="/var/www/wp-content/uploads/redmine_uploads/emptyTextFile.txt"
    Content-Type: application/octet-stream</p>
    
    <p>------------------------------dde946a683ac--</p>
  </blockquote>
  
  <p>Any ideas why this is happening?</p>