从jQuery的发送了AJAX的图像数据送了、图像、数据、jQuery

由网友(希冀)分享简介:我需要发送图像数据(数据:图像/ PNG; BASE64)使用AJAX来我的PHP服务器的客户方。我的AJAX调用看起来是这样的:(form_data包含图像)I need to send image data (data:image/png;base64) from the clientside using AJA...

我需要发送图像数据(数据:图像/ PNG; BASE64)使用AJAX来我的PHP服务器的客户方。我的AJAX调用看起来是这样的:(form_data包含图像)

I need to send image data (data:image/png;base64) from the clientside using AJAX to my PHP server. My AJAX call looks like this:(form_data contains the image)

$.ajax({
    url: global_siteurl+'/save_image',
    data: form_data,
    dataType: 'json',
    type: 'post',
    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
    success: function (retval) {   
        process_save_image(retval);
    }
});

然后我存储连接codeD映像数据在数据库中的BLOB(是的 - 背后很长的故事!)。当我获取图像数据似乎已损坏,无法正确显示。仿佛有换行和空格引入到图像数据。我失去了我的ajax调用的任何参数?任何想法,以什么可能去错了吗?有没有大小限制的图像数据,我可以送过去吗?

Then I store the encoded image data as a blob in the database (yes - long story behind that!). When I retrieve the image data it seems to be corrupted and does not display correctly. Almost as if there are line breaks and spaces introduced into the image data. Am I missing any parameters in my ajax call? Any ideas as to what may be going wrong? Is there a size limit for the image data I can send across?

这是一个漫长的4天追逐这一个。

It's been a long 4 days of chasing this one.

Mmiz

推荐答案

原来,这个问题是一样的在这个帖子中描述(及解决):

The problem turned out to be the same described (and solved) in this posting:

斑点数据与空间代替'+'

原来我需要做BLOB数据安全的网址,当我GET / POST它。在PHP服务器侧I使用上述帐中描述的功能。在JavaScript端,我使用的功能来自:

Turns out I needed to make the blob data safe for URLs when I GET/POST it. On the PHP server side I used the function described in the above posting. On the Javascript side, I used the functions from:

的http://notepad2.blogspot.com/2012/08/javascript-make-base64-en$c$cd-string.html

拍了很多盯着EN $ C $光盘镜像数据来注意到+ / =被替换。

Took a lot of staring at the encoded image data to notice that the +/= were replaced.

阅读全文

相关推荐

最新文章