curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
Also verify that the file permissions are correct.
.......
function onsweb_apply_form_validate($form, &$form_state) {
$file = file_save_upload('wb_file_resume', array(
'file_validate_extensions' => array('docx doc pdf'),
));
if ($file) {
if ($file = file_move($file, 'public://')) {
$form_state['values']['wb_file_resume'] = $file;
} else {
form_set_error($key, t('Failed to write the uploaded file the site\'s file folder.'));
}
} else {
form_set_error($key, t('No file was uploaded.'));
}
}
// FYI, this function is being called after the validation function
function onsweb_apply_form_submit($form, &$form_state) {
$options = array('transaction_code' => '{{YOUR_CODE_HERE}}');
$options['id'] = $form_state['values']['item_id']; // The ID of the vacancy as in context
foreach ($form_state['values'] as $key => $value) {
if (strstr($key, 'wb_file_')) {
$file = $value;
$file->status = FILE_STATUS_PERMANENT; // Drupal thingy
file_save($file);
$wrapper = file_stream_wrapper_get_instance_by_uri($file->uri);
$options[str_replace('wb_file_', '', $key)] = new \CURLFile($wrapper->realpath());
}
if (strstr($key, 'wb_') && !strstr($key, 'wb_file_')) $options[str_replace('wb_', '', $key)] = $value;
}
// Copy pasted the _do function from the Catsone API V2
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://infomedics.catsone.nl/api/apply_joborder');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 90);
curl_setopt($ch, CURLOPT_TIMEOUT, 90);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_POST, true);
if (defined('CURLOPT_SAFE_UPLOAD')) {
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $options);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
$result = curl_exec($ch);
$xml = simplexml_load_string($result);
curl_close ($ch);
if (!$xml) {
drupal_set_message(t('Something Wong'), 'error');
}
if ($xml['success'] !== 'true') {
drupal_set_message(t('All Cool'));
}
}