3

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?

4

1 回答 1

1

一种解决方案是在支持时使用 File API,而对于不支持 File API 的浏览器,则回退到Flash Player 。

将 Flash 中的 ByteArray 转换为 Base64 字符串非常容易。我通常使用com.sociodox.utils.Base64因为编码性能很好。

于 2013-05-23T14:53:59.960 回答