Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Phonegap显示路径为';cdvfile://localhost/persistent'_Android_Cordova - Fatal编程技术网

Android Phonegap显示路径为';cdvfile://localhost/persistent'

Android Phonegap显示路径为';cdvfile://localhost/persistent',android,cordova,Android,Cordova,我目前正在用phonegap开发一个应用程序,我想更新wordpress上我的应用程序的内容。通过JSON API,我获得了页面的html内容,但问题是让用户选择图像。我所做的是从wordpress向我的智能手机发送一个zip,其中包含新的html内容和新的图像。 我下载zip文件,应用新的html内容,并将图像复制到cdvfile://localhost/persistent'将其转换为带有phonegap的“/storage/emulated/0/”,因为我在Android手机上使用它。我想

我目前正在用phonegap开发一个应用程序,我想更新wordpress上我的应用程序的内容。通过JSON API,我获得了页面的html内容,但问题是让用户选择图像。我所做的是从wordpress向我的智能手机发送一个zip,其中包含新的html内容和新的图像。 我下载zip文件,应用新的html内容,并将图像复制到cdvfile://localhost/persistent'将其转换为带有phonegap的“/storage/emulated/0/”,因为我在Android手机上使用它。我想在html页面中显示图像,但我不知道访问“/storage/emulated/0/”的链接,我尝试了该链接”file:///storage/emulated/0/img.png“但是什么也没有出现。。。有什么想法吗?
我仍在考虑使用,但我担心用它代替我的方式会更慢…

最后是由于其他错误。 要使用phonegap显示“存储/模拟/0/”中的图像,请执行以下操作:

<img src="cdvfile://localhost/persistent/img/photo-241x300.jpg" alt="">


工作正常。

在我的情况下,如果使用
我会出错

拒绝加载图像 'cdvfile://localhost/persistent/img/my-image.png因为它违反了法律 以下内容安全策略指令:“img src*”

为了解决这个问题,我将index.html更改为内容安全策略

<meta http-equiv="Content-Security-Policy" 
         content="style-src * 'self' 'unsafe-inline'; 
                  font-src * data:;
                  script-src * 'unsafe-inline' 'unsafe-eval';">

我删除规则
默认src*gap://ready 档案:;img src*数据:,现在我可以使用


警告:我的文件保存在
cordova.file.dataDirectory

中,您如何将图像保存到应用程序中的文件夹?关于我的应用程序,我从包含图像的服务器下载了一个zip,并在应用程序中解压。我不确定您是否完全理解我想要的内容。如果您愿意,您可以在此处检查此问题(请执行:)@trainoasis我像您一样注册图像”cdvfile://localhost/persistent/MyAppID/“并创建一个MyAppID文件夹。为什么不想在存储中创建文件夹?是否要在“www”文件夹中注册图像?是的,我希望它们存储在我的www文件夹中