I’m going to guess you need to use something like $_POST['token']['tokenVal'] to access the value you want, but my JS knowledge isn’t that good, and my ‘interaction between JS and PHP’ knowledge even less good.
When I echo var_dump($_POST); I get the "data:image/png;base64 string and when i echo echo $_POST['token']['tokenVal']; nothing is return or display and when I echo $_POST['tokenVal']; I get Notice: Undefined index: tokenVal in and var_dump($_POST['tokenVal']); return NULL.
The value is not yet pass… $_POST[‘token’]; still return Notice: Array to string conversion in C:\xampp7\htdocs\vvccccv\upload.php
Nope. What you need is to figure out what your data are. With regards to that your observations don’t make sense: you say that $_POST is a string, but it’s always an array (proof of that is that you get an array-to-string notice, not an undefined-index notice, as would be the case if $_POST were a string).
Which is totally not what it should contain to begin with (the expectation would be a hash and a number). There might be an issue with your JS to solve first.
I want to pass Session variable value to the ajax and able to access the value return by ajax … pls kindly help out if am not to use array for that…maybe that is where the problem is…
I was able to display the image…everything is working fine it just that am trying to secure the ajax request by adding token Id…well pls if you have any idea or code that I can use to secure ajax request I will appreciate that because that is what am trying to do
That is the part of the code that is giving me issue…
Okay…what am doing is am using Croppie script to crop images…after everything is fine I want to check session variable with the ajax request… below is the JS
Is there a scope issue with the location of the definition of form_data? As I said before, I’ve only played a bit with JS, and I suspect you might get a console error if that was the problem. If you display the value of it inside your click handler function, does it contain what you expect it to contain?
This part is not necessary. AJAX (i.e. XMLHttpRequest) automatically sends the cookies along (and hence the processing PHP script has access to the session data). So it would suffice to check on the server if the hash of the data is what is stored in the session.