...
let data = {
user_id: "UID",
base64: "b64"
};
let request= new XMLHttpRequest();
request.open("POST", "xxxxx.php", true);
request.setRequestHeader("Content-type", "application/json");
request.send(JSON.stringify(data));
...
$str_json = file_get_contents('php://input');
$jdom = json_decode($str_json);
if(!array_key_exists("base64", $jdom) || !array_key_exists("user_id", $jdom))
die("NO BASE64/UID");
$base64 = $jdom["base64"];
$user_id = $jdom["user_id"];
...