Skip to content

Commit

Permalink
fix binary files for ie11
Browse files Browse the repository at this point in the history
  • Loading branch information
vpegado committed Feb 23, 2016
1 parent 034ed9b commit e84ba4d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions angular-file-directive.js
Expand Up @@ -20,7 +20,13 @@ angular.module('ngFile', [])
var body = e.target.result;
// Base64 Encode file of type other than 'text'
if (!isText) {
body = btoa(body);
var binary = "";
var bytes = new Uint8Array(body);
var length = bytes.byteLength;
for (var i = 0; i < length; i++) {
binary += String.fromCharCode(bytes[i]);
}
body = btoa(binary);
}
// Compile data from file
files.push({
Expand All @@ -42,7 +48,7 @@ angular.module('ngFile', [])
if (isText) {
reader.readAsText(file);
} else {
reader.readAsBinaryString(file);
reader.readAsArrayBuffer(file);
}
});
});
Expand Down

0 comments on commit e84ba4d

Please sign in to comment.