You can use the HTMLcanvas for it: Create a canvas, load your image into it and. DataURL() to get the baserepresentation (actually, it’s a data: URL but it contains the base64-encoded image). This does not work when you create and add the img in JS, I believe.
I have a registration form where users can choose an avatar. Simply convert the default avatar to baseimage. Try utilizing XMLHttpRequest() set responseType to Blob , use FileReader() at.
JS: how can I baseencode a local file without XMLHttpRequest?
ASCII Plain Text (automatically encoded).