Jason Whitmer
unread,Feb 11, 2012, 9:54:15 PM2/11/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to phonegap
In iOS, I'm trying to write an html file to the WWW directory, so I
can link to it in my app. Using the same code I can write to the
Documents folder without an issue. How can I write an html file to the
WWW directory?
Thank you,
Jason
Here is my test code:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert('in onDeviceReady');
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS,
fail);
}
function gotFS(fileSystem) {
alert('in gotFS');
// var rootPath = fileSystem.root.fullPath; // THIS LINE WORKS
AND WRITES TO DOCUMENTS
var rootPath =
fileSystem.root.fullPath.substring(0,fileSystem.root.fullPath.lastIndexOf('/'))
+ '/Lightningbug.app/www/'; // THIS LINE DOES NOT WORK
fileSystem.root.getFile(rootPath + 'test.html', { create: true },
gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
alert('in gotFileEntry');
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
writer.onwrite = function(evt) {
alert("write success");
};
writer.write("some sample text");
}
function fail(error) {
alert('in failure: '+error.code);
}