How to preview picture stored in the fake path in Angular 2/Typescript?

后端 未结 4 570
逝去的感伤
逝去的感伤 2020-12-07 16:36

Browsers don\'t take full path of local disc, instead they concatenate the filename with fakepath. Is there any way to access the file (image) from fakepath using typescript

4条回答
  •  不思量自难忘°
    2020-12-07 17:18

    It's working

    example.component.html

    
     

    example.component.ts

    imageShow: any= '';
    onFileChanged(event) {
      this.file = event.target.files[0]
      var reader = new FileReader();
      reader.readAsDataURL(event.target.files[0]);
      reader.onload = (event) => {
       this.imageShow = (event.target).result;
     }
    

    }

提交回复
热议问题