Convert File to byte array Angular 2

旧时模样 提交于 2019-12-09 13:57:59

问题


How can I convert input file(image,for example) to byte array by using Angular2 ? Maybe someone can say what is better: convert image to byte array and send it to Web API or send the File "object" to API and there convert it?


回答1:


You wouldn't really use Angular for solving this task. JavaScript has APIs for handling File data, e.g. https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsArrayBuffer

See this question

PS: "Angular 2" is just called "Angular" now, because they're on version 4: http://angularjs.blogspot.com/2016/12/ok-let-me-explain-its-going-to-be.html

Unless you mean you are using an older version of Angular.



来源:https://stackoverflow.com/questions/45267800/convert-file-to-byte-array-angular-2

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