const useMedia = (query) => {
const windowGlobal = typeof window !== 'undefined' && window
const [matches, setMatches] = useState(false)
useEffect(() => {
if (windowGlobal) {
const media = windowGlobal.matchMedia(query)
if (media.matches !== matches) setMatches(media.matches)
const listener = () => setMatches(media.matches)
media.addEventListener('change', listener)
return () => media.removeEventListener('change', listener)
}
}, [matches, query])
return matches
}
<form enctype="multipart/form-data" id="userForm" name="userForm">
<input type="text" name="FirstName" id="FirstName">
<input type="text" name="LastName" id="LastName">
<input type="email" name="Email" id="Email">
<div id="files">
<input type="file" id="application" name="application[]" class="inputfile2" multiple onChange="getBase64(this);" accept="application/pdf,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">
</div>
<button class="send" id="send-data">Send</button>
</form>
jQuery(document).ready(function($){
$('#send-candidate-data').on('click', function(e){
var formData = new FormData($(this).parents('form')[0]);
formData.append('action', 'soap_post');
e.preventDefault();
$.ajax({
url: '<?php echo admin_url("admin-ajax.php") ?>',
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function( data ) {
console.log( data );
}
});
});
});
function soap_post() {
$firstName = $_POST['FirstName'];
$lastName = $_POST['LastName'];
if(isset($_POST)) {
$name = $_FILES['application']['name'];
$size = $_FILES['application']['size'];
$type = $_FILES['application']['type'];
$tmp_name = $_FILES['application']['tmp_name'];
print_r($name);
}
}
$.ajax({
url: '<?php echo admin_url("admin-ajax.php") ?>',
type: 'POST',
data: {
action: 'soap_post',
firstName: firstName,
lastName: lastName,
phone: phone,
email: email,
comment: comment,
refCode: ref_code,
clientKey: client_key,
gender: selectedGender,
application: newFiles
},
});
data: {
action: 'soap_post',
datas: formData
},
$.ajax({
url: '<?php echo admin_url("admin-ajax.php") ?>',
type: 'POST',
data: {
action: 'soap_post',
firstName: firstName,
lastName: lastName,
phone: phone,
email: email,
comment: comment,
refCode: ref_code,
clientKey: client_key,
gender: selectedGender,
application: newFiles
},
dataType: 'text',
success: function( data ) {
console.log( data );
}
});
foreach ($result_data as $job) {
$ref_code = $job->RefCode;
if (!$ref_code ) {
$parser_url = 'https://mytestlink.com/' . $ref_code . '/';
$ch = curl_init($parser_url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($retcode === 200) {
$html = file_get_html(rtrim($image_url));
$contact = $html->find( "." . 'contact-right', 0)->innertext;
update_field( 'contact_details', $contact, $post_->ID );
$img_src = $html->find( "." . 'contact-left' . ' > img', 0)->src;
update_field( 'foto', $image_url . $img_src, $post_->ID );
}
curl_close($ch);
}