Is there a way to preview a doc file before uploading it? I can successfully view pdf, png, and jpg files in an iframe using their base64 data. But for Doc, Docx, PPTX, and XLSX files, I am unable to display them in the iframe.
<input type="file" #file placeholder="Choose file" (change)="uploadFile(file)">
<iframe [src]="base64File"></iframe>
uploadFile(file) {
let reader = new FileReader();
reader.readAsDataURL(data.files[0]);
reader.onload = (_event) => {
this.base64File= this._sanitizer.bypassSecurityTrustResourceUrl(reader.result);
}
I have tried using ngx-doc-viewer, but it does not support viewing files with base64 data - only file paths. Since I cannot access the file path from the local hard drive during upload, angular restricts me from using that path even if I manage to obtain it.