通过AJAX无法使用Fat-free Framework的图像字符串

时间:2016-07-20 00:08:17

标签: javascript php jquery ajax fat-free-framework

我正在尝试将图像作为字符串上传,这是我使用Croppie.js运行到运行Fat-Free Framework的服务器。我已经在$.ajax()调用之前验证了数据,但我的PHP无法显示它。如果我注释掉处理发布的图像数据,其他数据(如电子邮件)就会显示出来。这是我的Javascript:

$picturePreview.croppie('result').then(function (imageData) {
  // imageData is processed below to pop off the beginning of
  // the Base64 string including the filetype and base information

  var postData = {
      email         : $('#email').val(),
      picture       : imageData.substr(imageData.indexOf(',') + 1)
    };

  $.ajax({
    method: 'POST',
    url: 'user',
    data: postData,
    beforeSend: function() {
      // This returns all data, including the image string:
      console.log(postData);
    }
  });
});

这是我的用户类的post函数,它正确映射:

function post($f3) {
  global $handler; // This is a global variable for PhpConsole

  $email =          $f3->get('POST.email');
  $picture =        $f3->get('POST.picture');
  // I've tried limiting the above to 4 characters and it still won't work

  $handler->debug($email, "heres the email"); // This outputs fine if the next line is commented out
  $handler->debug($picture, "heres the pic");
}

我还尝试将php_value的{​​{1}}增加到post_max_size,但仍然没有。为什么包含图像数据的Base64字符串会破坏我的应用?我应该采取另一种方式吗?

0 个答案:

没有答案