0

I got error in ionic 3(android) at load image on from local phone or sd-card storage,

path="file:///storage/emulated/0/Download/1533311989863.png"

<img [src]="path" > </img>

I also tried,

path="file://storage/emulated/0/Download/1533311989863.png"

OutPut:-

Not allowed to load local resource: file:///storage/emulated/0/Download/1533311989863.png
NIKUNJ GADHIYA
  • 103
  • 2
  • 14

1 Answers1

1

Read as base64 from filesystem using ionic-native File plugin:

File.readAsDataURL(cordova.file.dataDirectory, fileUrl).then(imageBase64 => {
self.urlToShow = imageBase64;
});

Sanitize the base64 url:

    get imageURLSanitized() {
    return this.sanitizer.bypassSecurityTrustUrl(this.urlToShow);

}

in HTML use sanitized url as [src]

<img [src]=“imageURLSanitized”>
Kevin Dias
  • 1,043
  • 10
  • 28