Skip to content

Instantly share code, notes, and snippets.

@barbotkin
Last active February 2, 2017 15:17
Show Gist options
  • Save barbotkin/7439ccecea7b2a167dd504116d31daad to your computer and use it in GitHub Desktop.
Save barbotkin/7439ccecea7b2a167dd504116d31daad to your computer and use it in GitHub Desktop.
Code File Upload Resume to Bullhorn PHP API
<?php
// File Upload Resume
$data = "file/Candidate/".$candidate->changedEntityId."/raw?externalID=UserHeadshot&fileType=CV&type=CV&BhRestToken=".$token;
$fileName = $_FILES['file']['name'];
$filePath = $_FILES['file']['tmp_name'];
$post = file_get_contents(''.$filePath.'');
$eol = "\r\n";
$separator = ''.md5(microtime()).'';
$requestBody = '';
$requestBody .= '--'.$separator. $eol;
$requestBody .= 'Content-Disposition: form-data; name="resume"; filename="'.$fileName.'"'. $eol;
$requestBody .= 'Content-Length: "'.strlen($post).'"'. $eol;
$requestBody .= 'Content-Type: text/html'.$eol;
$requestBody .= 'Content-Transfer-Encoding: binary'. $eol. $eol;
$requestBody .= ''.$post.''. $eol;
$requestBody .= '--'.$separator.'--'. $eol . $eol;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $apilink.$data);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: multipart/form-data; boundary='.$separator.''));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
$response = curl_exec($curl);
curl_close($curl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment