Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load local image into canvas without using file API

I am creating a javascript application that is communicating with a REST web server, to add an image I have to convert it to base64. To convert the image to base64 I was going to use canvas toDataUrl() but to load a local file I need to use the File API which is not that well supported (I need to support at least IE9). Is there a way how I can achieve this without using the file API and without using the server?

like image 329
CodePorter Avatar asked Jun 25 '26 17:06

CodePorter


1 Answers

One solution would be to use the File API when supported and fall back to Flash Player for browsers that don't support the File API.

It pretty easy to convert a ByteArray in Flash into a Base64 string. I usually use com.sociodox.utils.Base64 because the encoding performance is great.

like image 169
Strille Avatar answered Jun 27 '26 07:06

Strille



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!