1

I'm trying to convert an image into base64 using javascript, however if I request the URL with jquery, and encode with javascript, the results are different than what I receive from here (http://www.scalora.org/projects/uriencoder/) when saving and uploading the image..

Is there any reason for this?

I'm just using $.get and base64 encoding function data()

1
  • What happens if you drop the image into Hashify. Does the Base64 string in the resulting data URI match either of the strings you generated? Commented Nov 4, 2011 at 4:31

1 Answer 1

1

Another SO Question covers this exact topic and has a solution that works for IE and Firefox. The short answer is that XHR really isn't designed for binary data and the data gets corrupted or truncated when converted to a string for XHR.responseText.

It would be best to Base 64 encode on the server side.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.