Is it possible to convert an selected image into base64 encoded string?
Would be nice and easy solution for image uploader. :)
Thanks ;)
Is it possible to convert an selected image into base64 encoded string?
Would be nice and easy solution for image uploader. :)
Thanks ;)
If you're wanting to encode the byteArray of a loaded image, you could use the Base64Encoder class from mx.utils Base64Encoder.
Something like:
I had to track down the class here.
Also, there's another Base64 class that I found but haven't tested here...but looks like it works similarly.
Hope that helps.
You can save an image as a Base64-string, but I wouldn't recommend it. I have tried doing this and it slows down your application a lot.
If you still want to do this, you should download the Base64-class at this link: http://garry-lachman.com/2010/04/21/base64-encoding-class-in-actionscript-3/
If you then get the bitmapData from your image, you can call for the .getPixels()-method, which returns a bytearray. This bytearray can be converted to a Base64-string using the class in the link.
If you want to load images from a Base64-string, you can create a Loader-object and use the loadBytes()-method to load in the byteArray you get by decoding your Base64-string.
Hope this helps :)