when user uploads a file, I want to show preview of the document but i can't find the way how to do it.
what I am doing is
<input id="FileFrame" type="file" ng-file-select="onFileSelect($files)" ng-click="resetInputFile()">
In my controller read the file as readAsBinaryString
var fileReaders = new FileReader();
fileReaders.readAsBinaryString($files[i]);
var loadFile = function(fileReaders, index) {
fileReaders.onload = function(e) {
$timeout(function() {
$scope.dataUrlss = e.target.result;
});
}
}(fileReaders, i);
Im giving dataUrlss to iframe, but it won't works..
<iframe ng-show="dataUrlss != null" src="about:blank" style="width: 90%; height: 300px" name="internal"></iframe>
Thanks..
I added new code like
var doc = document.getElementById('FileFrame').contentWindow.document;
doc.open();
doc.write($scope.dataUrlss);
doc.close();
but it prints in different format.