0

Tried to view files on my HTML but there seems to be nothing showing, after fixing the sanitizer issues.

This is my Html:

<embed [src]='trustTwo' width="800px" height="2100px" type='application/pdf'/>

This is the ts file

public filePreview = '';
trustTwo = null;`

this.trustTwo = sanitizer.bypassSecurityTrustResourceUrl(this.filePreview);`

onFilePicked(event: Event) {
    const filePicked = (event.target as HTMLInputElement).files[0];
    this.form.patchValue({ file: filePicked });
    this.form.get('file').updateValueAndValidity();
    const reader = new FileReader();
    reader.onload = () => {
      this.filePreview = reader.result;
    };
    reader.readAsDataURL(filePicked);
}

Can anyone point me in the right direction, currently the files upload to the server but I am trying to display the files on the HTML. If this is the completely wrong way to go about it, please suggest any alternatives.

Avinash
  • 1,225
  • 10
  • 18
Andrew
  • 663
  • 1
  • 8
  • 23
  • Possible duplicate of [Recommended way to embed PDF in HTML?](https://stackoverflow.com/questions/291813/recommended-way-to-embed-pdf-in-html) – Faizan Virani Jun 27 '18 at 16:51
  • This is something I viewed, but it's not working, therefore asking if anyone has any other suggestions? – Andrew Jun 27 '18 at 17:21

0 Answers0