问题
Issue: Using Phonegap on iOS I want to copy a image from the application package example
http://localhost/img/test.png
to the local persistent storage.
I'm ok getting the persistent storage via window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail). But how do I get the folder of the www root? Per file plugin docs I assume I somehow need to use cordova.file.applicationDirectory. Unfortunately the doc doesn't specify where/how to do that. I've tried some ways but no luck so far.
Any ideas?
Environment: -Phonegap 3.4 - org.apache.cordova.file plugin 1.1.0 (https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md) - iOS Simulator 7.1.
回答1:
Ok, figured it out now.
1) Upgrade plugin to 1.2.0 2) Use window.resolveLocalFileSystemURL
Example: window.resolveLocalFileSystemURL(cordova.file.applicationDirectory+'/www/img', function(dirEntry){...}, errorHandler);
As phonegap files are always below www don't forget that folder.
回答2:
Upgrade your org.apache.cordova.file to 1.2.0
来源:https://stackoverflow.com/questions/24067878/phonegap-file-plugin-copy-file-from-app-package-to-persistent-storage