1

I need to send an image that has been converted to base64 by JavaScript, to a server. Lets assume I don't know anything about the server, except where to send the data. The image is a .jpg, so when JavaScript converted it, it prepended data:image/jpeg;base64 to the actual base64 data. So the result is something like this:

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA8ADwAAD/4V3gRXhpZgAATU0AKgAAAAg [...]

When researching on this topic, I found posts on SO that say keeping it will invalidate the base64 (here).

So, in general, should I strip the data:image/jpeg;base64 or keep it?

Community
  • 1
  • 1
somebodysomewhere
  • 1,102
  • 1
  • 13
  • 25

1 Answers1

1

You will definitely need to remove the data:image/jpeg;base64, if the server is only expecting a base64 string. If you don't know anything about the server, make sure it's setup to receive a base64 file at the very least.

David Boskovic
  • 1,469
  • 9
  • 14