Difference between readAsBinaryString() and readAsDataURL() in HTML5 FileReader API

天大地大妈咪最大 提交于 2019-12-04 15:08:44

If you use the readAsDataURL() you get the data back in a data URI format. So something like the src attribute here:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">

If you use the readAsBinaryString() the result will be a the raw bits. You can then use one of the low level binary API's to manipulate the data or post it to the server.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!