Reputation: 35
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?
Upvotes: 2
Views: 2044
Reputation: 57681
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.
Upvotes: 2
Reputation: 2209
Ithink you can use base64 javascript lib . I found this quite usefull in your case http://code.google.com/p/javascriptbase64/
Upvotes: 0