I'm trying to upload files to Redmine using the following PHP 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' => '@' . $filePath);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_POST, 1);
$token = curl_exec($curl);
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.
------------------------------dde946a683ac
Content-Disposition: form-data; name="file"; filename="/var/www/wp-content/uploads/redmine_uploads/emptyTextFile.txt" Content-Type: application/octet-stream
------------------------------dde946a683ac--
Any ideas why this is happening?