Angular 9 domSanitazer Not allowed to load resource

49 Views Asked by At

I have application in Angular 9 and use DomSanitazer to build img url. I get error:

Not allowed to load local resource: file:///C:/MyApp/Images/uploads/fbf8152f-ccea-45a2-b9a9-150cd4c421a5/mmm_3424.png

In component.ts I have:

import {
  SafeResourceUrl,
  DomSanitizer
} from '@angular/platform-browser';

  public avatarSafeFileUrl: SafeResourceUrl;

and when I load img:

this.avatarSafeFileUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(this.myAvatar.filePath);

In html I have:

<img [src]="avatarSafeFileUrl"  />

And I get error like above.

0

There are 0 best solutions below