2

I am trying to have a image insertion system. I've been able to get local images and also images by URL, but i need to base64 encode the url images before transmission to the server. Is there anyway to do it?

The local images are encoded automatically when we read them with readAsURL. How do I handle URLs in a similar fashion?

1
  • You probably mean readAsDataURL() from the File API? And what you want is a base64-encoded data: URL? Commented Jul 1, 2011 at 7:50

2 Answers 2

2

If I understand correctly you want to take the URL to some image on the web and turn it into a base64-encoded data: URL (similarly to what readAsDataURL() would return). This won't be possible because of same-origin policy - images that you load from other sites might contain sensitive data, you are only allowed to show them to the user but not to read out their data. You might be able to do it if that other site cooperates (via CORS) but I doubt that you want to rely on it. So you won't be able to implement this on the client side - you should send the URL to your server and the server should then download the image.

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

Comments

0

Ithink you can use base64 javascript lib . I found this quite usefull in your case http://code.google.com/p/javascriptbase64/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.