How to attach files to Atlassian Confluence page using PHP
<p>I'm working on attaching files via PHP to confluence (version 5.9.10)</p>

<p>Here is my code</p>

<pre><code>$ch=curl_init();
$headers = array(
    'X-Atlassian-Token: no-check'
);
$data = array('file' =&gt; '@test.txt');
curl_setopt_array(
    $ch,
    array(
        CURLOPT_URL=&gt;'https://&lt;path_to_confluence&gt;/rest/api/content/&lt;page_id&gt;/child/attachment',
        CURLOPT_POST=&gt;true,
        CURLOPT_VERBOSE=&gt;1,
        CURLOPT_POSTFIELDS=&gt;$data,
        CURLOPT_SSL_VERIFYHOST=&gt; 0,
        CURLOPT_SSL_VERIFYPEER=&gt; 0,
        CURLOPT_RETURNTRANSFER=&gt;true,
        CURLOPT_HEADER=&gt;false,
        CURLOPT_HTTPHEADER=&gt; $headers,
        CURLOPT_USERPWD=&gt;C_USERNAME.":".C_PASSWORD
    )
);
$result=curl_exec($ch);
$ch_error = curl_error($ch);
if ($ch_error) {
    echo "cURL Error: $ch_error";
} else {
    var_dump($result);
}
curl_close($ch);
</code></pre>

<p>But after running script I've next error:
    ></p>

<blockquote>
  <p>HTTP/1.1 500 Internal Server Error<br>
  Server: nginx/1.5.12<br>
  Date: Thu, 03 Nov 2016 10:12:44 GMT<br>
  Content-Type: application/json<br>
  Transfer-Encoding: chunked<br>
  Connection: keep-alive<br>
  X-ASEN: SEN-2160053<br>
  Set-Cookie: JSESSIONID=EE3116DFC552C7D4571608BFCF410559; Path=/; HttpOnly<br>
  X-Seraph-LoginReason: OK<br>
  X-AUSERNAME: user<br>
  Cache-Control: no-cache, must-revalidate<br>
  Expires: Thu, 01 Jan 1970 00:00:00 GMT<br>
  X-Content-Type-Options: nosniff<br>
  HTTP error before end of send, stop sending<br>
  Closing connection 0
  string(93)  "statusCode":500,"message":"java.lang.IllegalArgumentException:File name must  not be null"
  </p>
</blockquote>

<p>What I'm doing wrong? What have I missed?</p>