您的位置:首页 > 其它

web 开发之创建本地文件夹的实现方法

2017-08-03 14:34 465 查看

web 开发之创建本地文件夹的实现方法

 filemanage_util.fullPath 就是创建文件的路径

这是跨平台的创建文件夹,不像Android那样还要通过 Environment.getExternalStorageDirectory() 的原生代码来创建

实现代码:

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
// alert('ondeviceReady');
// window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
console.log("文档中心===========>软件准备就绪:设置检测文件存储目录开始.");
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
console.log("文档中心===========>检测临时文件存储目录方法");
//util.appRootDirName 全局变量,这里是zgky
fileSystem.root.getDirectory(filemanage_util.appRootDirName, {
create: true,
exclusive: false
}, function (entry) {
//网上流传的资料中都是使用fullPath,在这里我获取到的是相对目录,在下载时使用会报错,所以换做了toURL()
//这是一个全局全局变量,用以保存路径
console.log("文档中心===========>创建文件夹成功,正在设置相关的参数!");
filemanage_util.fullPath = entry.toURL();
// alert(util.fullPath);
console.log("文档中心===========>创建文件夹成功:" + filemanage_util.fullPath);
//console.log(util.fullPath);
}, function () {
console.log("文档中心===========>创建文件夹失败!");
});
console.log("文档中心===========>检测临时文件目录方法结束!");
}, function () {
console.log("文档中心===========>创建文件夹失败");
});
console.log("文档中心===========>软件准备就绪:设置检测文件存储目录结束");
};

以上就是web创建本地文件夹的实现方法,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  web 文件夹