试图在我的HTML上查看文件,但是在解决了消毒剂问题之后似乎没有任何显示。
这是我的HTML
<embed [src]='trustTwo' width="800px" height="2100px" type='application/pdf'/>
这是ts文件
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);
}
任何人都可以向我指出正确的方向,当前文件已上传到服务器,但是我试图在HTML上显示文件。如果这样做是完全错误的方法,请提出其他选择。