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.