小编Nic*_*ale的帖子

"不允许为PhoneGap Build中的远程页面中的本地映像加载本地资源"

我正在为一个phonegap构建应用程序托管我的网页.我想使用相机上传照片,并显示预览图像,基本上这样做:

<img src="file:///storage/emulated/0/Android/data/com.myapp.myapp/cache/1470418568917.jpg" height="500" />
Run Code Online (Sandbox Code Playgroud)

因为我的网页是托管的,我收到此错误:

不允许加载本地资源: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:">
Run Code Online (Sandbox Code Playgroud)

这到我的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 …
Run Code Online (Sandbox Code Playgroud)

image cors cordova phonegap-build

19
推荐指数
3
解决办法
2万
查看次数

标签 统计

cordova ×1

cors ×1

image ×1

phonegap-build ×1