当前位置: 移动技术网 > IT编程>开发语言>Java > web 开发之创建本地文件夹的实现方法

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

2017年12月08日  | 移动技术网IT编程  | 我要评论

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创建本地文件夹的实现方法,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网