Despite trying various solutions to access a file in the www folder, none seem to work for me. I am testing the application on iOS with the iOS simulator.
The specific file I want to access is test.txt
located in the www folder.
Here is my current approach:
var filePathURI = getPhoneGapPath() + "test.txt";
window.resolveLocalFileSystemURI(filePathURI, onResolveSuccess, onFail);
function getPhoneGapPath() {
'use strict';
var path = window.location.pathname;
var phoneGapPath = path.substring(0, path.lastIndexOf('/') + 1);
return phoneGapPath;
};
Unfortunately, this solution is not working as expected. I keep getting an error with errorCode = 2
, indicating FileError.SECURITY_ERR
. Regardless of what I try, I cannot access the file using resolveLocalFileSystemURI
.
INFO: I have attempted the following filePathURI
s:
- /Users/UserName/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/GUID/AppName.app/www/test.txt
- file:///Users/UserName/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/GUID/AppName.app/www/test.txt
If anyone has a solution that actually works, I would greatly appreciate it.