Trying to get json array from ajax, but when i'm trying to write it down in the text file, it shows nothing.
var img = JSON.parse(localStorage.getItem("iPath"));
var img = JSON.stringify(img);
console.log(img);
$.ajax({
url: './php/temporary.php?deletefile',
cache: false,
type: 'POST',
data: img,
success: function( respond, textStatus, jqXHR ){
if( typeof respond.error === 'undefined' ){
//window.location.assign("/buyplace.html");
}
else{
console.log('ОШИБКИ ОТВЕТА сервера: ' + respond.error );
}
},
error: function( jqXHR, textStatus, errorThrown ){
console.log('ОШИБКИ AJAX запроса: ' + textStatus );
}
});
if( isset( $_GET['deletefile'] ) ){
$params = json_decode( $_POST);
$myfile = fopen("testfile.txt", "w");
fwrite($myfile, $params);
//$img = "uploads/" . $imgPath;
//move_uploaded_file($imgPath, "./uploads/");
//unlink('./uploads/' . $img);
}
?>
How can i solve this problem?
$jsondata = json_decode(file_get_contents('php://input'))$_GET['deletefile']is on the URL line, so it should still be populated.$_GET['deletefile']is fine, it is the data that is not being accessed correctly.imgcontain?