File: /home/kochikidswysewor/public_html/wp-content/themes/children-charity-child/update-feedback.php
<?php
include '../../../wp-load.php';
if($_REQUEST['action']===""){
echo "<script>alert('Invalid data!');window.location.href='".get_site_url()."'</script>";
}
if ( $_REQUEST['action']=="agent-feedback" ){
$donation_id=$_POST['donation_id'];
$feedback=$_POST['feedback'];
$file_upload=$_FILES['file'];
$url = '';
if (isset($file_upload))
{
$uploadedfile = $file_upload['name'];
$upload_name = $file_upload['name'];
$uploads = wp_upload_dir();
if (!function_exists('wp_handle_upload'))
{
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
// require_once ('../../../wp-admin/includes/image.php');
$upload_overrides = array(
'test_form' => false
);
$movefile = wp_handle_upload($file_upload, $upload_overrides);
if ($movefile && !isset($movefile['error']))
{
$file = $movefile['file'];
$url = $movefile['url'];
$type = $movefile['type'];
// media_handle_upload( $file_handler, 0 );
$attachment = array(
'post_mime_type' => $type,
'post_title' => $upload_name,
'post_parent' => $donation_id
//'post_parent' => 0 //IF DONT WANT TO ATTACH POST ID
);
$attach_id = wp_insert_attachment($attachment, $file, $donation_id);
// $attach_data = wp_generate_attachment_metadata($attach_id, $file);
// wp_update_attachment_metadata($attach_id, $attach_data);
// echo $postid = wp_insert_post( $my_post );
}
}
// echo $url;exit;
$sub_fields = array(
'agent_feedback' => $feedback,
'file_upload' => $url
);
update_field('field_6409ce90591b1', $sub_fields, $donation_id);
echo "updatefeedback";
}
if ( $_REQUEST['action']=="user-feedback" ){
$donation_id=$_POST['donation_id'];
$feedback=$_POST['feedback'];
$sub_fields = array(
'user_feedback' => $feedback,
);
update_field('field_6409ce90591b1', $sub_fields, $donation_id);
echo "updatefeedback";
}
?>