Skip to content

Instantly share code, notes, and snippets.

@martinbean
Created June 23, 2011 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinbean/1042394 to your computer and use it in GitHub Desktop.
Save martinbean/1042394 to your computer and use it in GitHub Desktop.
<?php
$file_to_upload = array(
'ticket_attachment[attachment]' => '@' . $_SERVER['DOCUMENT_ROOT'] . '/nmsworkbacklog/crown.jpg',
'ticket_attachment[description]' => 'test description'
);
$headers = array();
$headers[] = 'Authorization: Basic ' . base64_encode('nms/martinbean:' . $this->registry->get('authenticate')->getApiKey());
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://api3.codebasehq.com/api-test-project/tickets/146/attachments');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $file_to_upload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
echo $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment