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

后端 未结 4 577
逝去的感伤
逝去的感伤 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:31

    Adding to @GünterZöchbauer answer, this wasn't working for me until I added this:

    reader.onload = function(e:any){
       this.url = e.target.result;
    }
    

    Prior to adding 'any', I was getting the error:

    property 'result' does not exist on type 'eventtarget' 
    

提交回复
热议问题