如何从本地音频文件生成base64字符串?
我需要通过socket.io作为base 64 string
发送我实际上使用angularjs
angular.module('starter.controllers', [])
.controller('DashCtrl', function () {
var handleFileSelect = function (evt) {
var file = evt.target.files[0];
var reader = new FileReader();
// this is the path of the file that i will have to send to the server
// /android_asset/www/sounds/button-1.mp3
reader.onload = function (readerEvt) {
var binaryString = readerEvt.target.result;
document.getElementById("base64textarea").value = btoa(binaryString);
};
reader.readAsBinaryString(file);
};
});