I am trying to pass some form data to a php page using JSON as shown below.
 var file = doc.output('blob');
                var fd = new FormData();     // To carry on your data  
                fd.append('mypdf',file);
                fd.append('x','<?php echo $_GET['x']?>');
               // alert('file');
                $.ajax({
                  url: 'week-distribute.php',   //here is also a problem, depends on your 
                  data: fd,           //backend language, it may looks like '/model/send.php'
                  dataType: 'text',
                  processData: false,
                  contentType: false,
                  type: 'POST',
                  success: function (response) {
                    console.log('Success to send request');
                  },
                  error: function (jqXHR) {
                    console.log('Failure to send request');
                  }
                });
The problem I have is that I cannot figure out how to retrive the data from the JSON object. I have tried the following (along with many other attempts) but this does not seem to work. Does anyone know how I can tried both the values x and mypdf please?
$json_data = file_get_contents("php://input");
$data = json_decode($json_data, true);
$x = $data["x"]; //This does not work
$target_file = basename($_FILES["mypdf"]["name"]).uniqid().'.pdf'; //This does not work
This is how the form data is passed across in the headers:
mypdf: (binary) x: eyJ0eXAiOiJKV1QiLCJh
 
    