You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INSERT SHORT DESCRIPTION EXPLAINING THE HIGH-LEVEL REASON FOR THE NEW ISSUE HERE.
We need to upload CV file(s) to "files" tab in career portal programmically (PDF, DOC, TXT Files) but we have struggled to get this to work with the files uploading being blanks. Any advice or help is appreciated to get this sorted immediately. I have added so of the code here but have attached the TXT file which has the full code so far.
INSERT SHORT DESCRIPTION EXPLAINING THE HIGH-LEVEL REASON FOR THE NEW ISSUE HERE.
We need to upload CV file(s) to "files" tab in career portal programmically (PDF, DOC, TXT Files) but we have struggled to get this to work with the files uploading being blanks. Any advice or help is appreciated to get this sorted immediately. I have added so of the code here but have attached the TXT file which has the full code so far.
recruitment_single.txt
Current behavior
Expected behavior
What has happened?
Codes in question
`function makeHttpRequestUpload($baseURL = '', $method, $options = array(), $restToken = []) {
$url = $baseURL.$method;
$postdata = $options;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $postdata,
CURLOPT_HTTPHEADER => array(
"BhRestToken: ".$restToken
),
));
$response = curl_exec($curl);
curl_close($curl);
$content = json_decode($response);
return $content;
}
function makeHttpRequestFileUpload($baseURL = '', $method, $options = array(), $options2 = array(), $restToken = []) {
$url = $baseURL.$method;
$post = file_get_contents(''.$options2.'');
$eol = "\r\n";
$separator = ''.md5(microtime()).'';
$requestBody = '';
$requestBody .= '--'.$separator. $eol;
$requestBody .= 'Content-Disposition: form-data; name="resume"; filename="'.$options.'"'. $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_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => $requestBody,
CURLOPT_HTTPHEADER => array(
"BhRestToken: ".$restToken,
'Content-type: multipart/form-data; boundary='.$separator.''
),
));
$response = curl_exec($curl);
curl_close($curl);
$content = json_decode($response);
return $content;
}
function attachFileToCandidate($postFileDataName, $postFileData, $candidateIDNumber){
BHConnect();
$method = 'file/Candidate/'.$candidateIDNumber.'/raw?fileType=SAMPLE&type=CV&externalID=portfolio';
$response = makeHttpRequestFileUpload($_SESSION['BH']['restURL'], $method, $postFileDataName, $postFileData, $_SESSION['BH']['restToken']);
return $response;
}
if(isset($_POST) && !empty($_POST) && !empty($_FILES)){
$postFileDataName = [
"fileName" => new CURLFILE($_FILES['resume']['name'])
];
$postFileData = [
"file" => new CURLFILE($_FILES['resume']['tmp_name'])
];
$resumeData = parseToCandidate($postFileData);
if (isset($resumeData->html)) {
$postData = [
"firstName" => $_POST['first_name'],
"lastName" => $_POST['last_name'],
"email" => $_POST['email'],
"description" => $resumeData->html,
"name" => $_POST['first_name']." ".$_POST['last_name'],
"category" => ["id"=> 2000021],
"mobile" => $_POST['phone'],
"source" => $_POST['description'],
"comments" => $_POST['cover_letter'],
"companyURL" => $_POST['company_website'],
"desiredLocations" => $_POST['desired_locations'],
"customText1" => $_POST['linkedin'],
"customText2" => $_POST['sponsorship'],
"status" => "Pre-Registered",
];
$check_candidate_exist = checkCandidateExist($_POST['first_name'],$_POST['last_name'],$_POST['email']);
if (isset($check_candidate_exist->total) && $check_candidate_exist->total > 0) {
$candidate = new stdClass();
$candidate->changedEntityId = $check_candidate_exist->data[0]->id;
} else {
$candidate = getBHCreateCandidate($postData);
}
if (isset($candidate->changedEntityId)) {
$candidateIDNumber = $candidate->changedEntityId;
$attachedFile = attachFileToCandidate($postFileDataName, $postFileData, $candidateIDNumber);
$newPostData = [
"dateWebResponse"=> "1370522348880",
"candidate"=> ["id"=> $candidate->changedEntityId],
"jobOrder"=> ["id"=>$_REQUEST['id']],
"comments" => $_POST['cover_letter']
];
$applyJob = submitBHJobSubmission($newPostData);
if (isset($applyJob->changeType)) {
$_SESSION['success_msg'] = "You have applied successfully.";
} else {
$_SESSION['error_msg'] = "Something went wrong. Please try again.";
}
}
} else {
$_SESSION['error_msg'] = "Something went wrong on CV uploads";
}
}
?>`
The text was updated successfully, but these errors were encountered: