Sending image data via AJAX from jquery

I need to send image data (data: image / png; base64) from a client using AJAX to my PHP server. My AJAX call looks like this: (form_data contains an 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);
    }
});

Then I save the encoded image data as a blob in the database (yes - a long story behind this!). When I retrieve the image data, it seems corrupted and does not display correctly. It’s almost as if there are line breaks and spaces in the image data. Am I missing any parameters in my ajax call? Any ideas on what could go wrong? Is there a size limit for image data that I can send?

It has been a long 4 days of chasing this.

Mmiz

+4
2

, ( ) :

Blob "+"

, blob URL-, GET/POST . PHP , . Javascript :

http://notepad2.blogspot.com/2012/08/javascript-make-base64-encoded-string.html

, , +/= .

+1

.

echo '<img src="data:image/png;base64,' . base64_encode($blob_data) . '"/>
0

All Articles