Skip to content Skip to sidebar Skip to footer

Sending Image Data Over Ajax From Jquery

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: glo

Solution 1:

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

Blob data replace '+' with space

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-encoded-string.html

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

Solution 2:

Try this when showing image.

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

Post a Comment for "Sending Image Data Over Ajax From Jquery"