![](/img/trans.png)
[英]Ionic Cordova FileUpload error: Not allowed to load local resource
[英]Ionic - Setting an image source as FILE_URI produces: Not allowed to load local resource error
我目前正在使用Android,并通过Ionic开发我的应用。 当用户拍照时,我会将其附加到离子幻灯片元素中的离子幻灯片上。 但是,我不断收到“不允许加载本地资源错误”。 设置所有权限(保存图像)
HTML:
<ion-slide *ngFor="let looImage of looImages">
<img src="{{ looImage }}" imageViewer ion-long-press
(onPressing)="showImageOptions()"/>
</ion-slide>
TS:
options: CameraOptions = {
correctOrientation: true,
quality: 50,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
};
capturePhoto() {
this.camera.getPicture(this.options).then((imageData) => {
this.looImages.push(imageData);
console.log(this.looImages.length);
}, (err) => {
});
}
完整错误:
不允许加载本地资源:file:///storage/emulated/0/Android/data/io.ionic.starter/cache/1538074314258.jpg
移动中的安全层拒绝从Web视图加载图像。 您可以使用“ DATA_URL”来返回base64内容。 您可以通过附加内容类型并应用DomSanitizer服务来附加到src属性。
如果仍要使用FILE_URI,请使用ionic-native / file插件https://ionicframework.com/docs/native/file/ ,可以将图像移到应用程序数据目录中,然后从那里访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.