Joh*_*mez 19 filesystems directory mobile cordova
试图找出如何使用PhoneGap在文件系统上创建目录.
我想为我的PhoneGap应用程序创建一个目录,这样我就可以存储用户在那里创建的图像并将其加载到应用程序中.
Tit*_*eul 40
这是你如何做到的:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onRequestFileSystemSuccess, null);
function onRequestFileSystemSuccess(fileSystem) {
var entry=fileSystem.root;
entry.getDirectory("example", {create: true, exclusive: false}, onGetDirectorySuccess, onGetDirectoryFail);
}
function onGetDirectorySuccess(dir) {
console.log("Created dir "+dir.name);
}
function onGetDirectoryFail(error) {
console.log("Error creating directory "+error.code);
}
Run Code Online (Sandbox Code Playgroud)
在iOS上,此脚本将在Applications/YOUR_APP/Documents /中创建名为"example"的目录