angularjs - How to show previews of selected documents -
angularjs - How to show previews of selected documents -
how can show preview of document. readasdataurl works previewing .pdf, .xls files?
var reader = new filereader(); reader.readasdataurl($files[i]); reader.onload = function (loadevent) { $scope.$apply(function () { $scope.dataurlss = loadevent.target.result; }); }; var doc = document.getelementbyid('fileframe').contentwindow.document; doc.open(); doc.write($scope.dataurlss); doc.close();
and iframe tag
<iframe id="fileframe" src="about:blank" style="height: 900px; width: 700px;"></iframe>
that solution didn't worked me.plz help me.thanks in advance...
this works (fiddle):
var reader = new filereader(); reader.addeventlistener("load", function (event) { var div = document.createelement("div"); div.innerhtml = '<object data="' + reader.result + '" type="'+file.type+'">' + '<embed src="' + reader.result + '" type="'+file.type+'" />' + '</object>'; output.insertbefore(div, null); }); //read file reader.readasdataurl(file);
partial code, see fiddle total thing. did not set in angular or iframe, issue neither technology, in way it's inserted. can modified work both. document types xls or xlsx might require additional work or might not possible embed @ all.
angularjs file iframe filereader preview
Comments
Post a Comment