我想从jQuery接收php中的base64图像,但我不知道如何在php中访问该值。
var tkpfu是Base64编码的图像,我将var放入了数据中,但是当我尝试在PHP中访问$_POST['tkpfl']时,会得到未定义变量thpfl的错误。
JavaScript:
function __SVTK(){
var data = {};
data['tkpfl'] = tkpfu;
console.log(data);
$.ajax({
type: 'POST',
url: 'profil/chatk',
data: data,
cache: false,
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
processData: false
}).done(function(data){
console.log(data);
}).fail(function(jqXHR,status,errorThrown){
console.log(errorThrown);
console.log(jqXHR.responseText);
console.log(jqXHR.status);
});
}
PHP:
var_dump($_POST);
Console log:
Internal Server Error profil:375
{"error":{"type":"ErrorException","message":"Undefined index: tkpfl","file":"\/Applications\/MAMP\/htdocs\/tender\/app\/controllers\/UsersController.php","line":66}} profil:376
500