【发布时间】:2016-12-12 05:48:33
【问题描述】:
我正在为 phonegap 构建应用托管我的网页。 我想用相机上传照片,并显示预览图像,基本上是这样做的:
<img src="file:///storage/emulated/0/Android/data/com.myapp.myapp/cache/1470418568917.jpg" height="500" />
因为我的页面是托管的,所以我收到了这个错误:
不允许加载本地资源:file:///storage/emulated/0/Android/data/com.myapp.myapp/cache/1470418568917.jpg”,来源:https://www.myapp.com/v5.5/imager.html#
我认为这是一些 CORS 问题,所以我已将其添加到页面的 html 中
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; media-src *; img-src * filesystem: data:">
这是我的 config.xml(我正在使用 Phonegap Build)
<plugin name="cordova-plugin-whitelist" source="npm" />
<allow-navigation href="*" />
<allow-navigation href="*://*/*" />
<allow-navigation href="file:///*/*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-intent href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<access origin="*" />
<access origin="*://*/*" />
<access origin="file:///*" />
<access origin="cdvfile://*" />
<access origin="content:///*" />
如您所见,我已经尝试了所有我能想到的设置,包括搜索网络。 我错过了什么明显的东西吗?
提前致谢。
【问题讨论】:
-
顺便说一下,iOS和Android都出现这个错误
标签: image cordova phonegap-build