web 開發(fā)之創(chuàng)建本地文件夾的實現(xiàn)方法
web 開發(fā)之創(chuàng)建本地文件夾的實現(xiàn)方法
filemanage_util.fullPath 就是創(chuàng)建文件的路徑
這是跨平臺的創(chuàng)建文件夾,不像Android那樣還要通過 Environment.getExternalStorageDirectory() 的原生代碼來創(chuàng)建
實現(xiàn)代碼:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
// alert('ondeviceReady');
// window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
console.log("文檔中心===========>軟件準(zhǔn)備就緒:設(shè)置檢測文件存儲目錄開始.");
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
console.log("文檔中心===========>檢測臨時文件存儲目錄方法");
//util.appRootDirName 全局變量,這里是zgky
fileSystem.root.getDirectory(filemanage_util.appRootDirName, {
create: true,
exclusive: false
}, function (entry) {
//網(wǎng)上流傳的資料中都是使用fullPath,在這里我獲取到的是相對目錄,在下載時使用會報錯,所以換做了toURL()
//這是一個全局全局變量,用以保存路徑
console.log("文檔中心===========>創(chuàng)建文件夾成功,正在設(shè)置相關(guān)的參數(shù)!");
filemanage_util.fullPath = entry.toURL();
// alert(util.fullPath);
console.log("文檔中心===========>創(chuàng)建文件夾成功:" + filemanage_util.fullPath);
//console.log(util.fullPath);
}, function () {
console.log("文檔中心===========>創(chuàng)建文件夾失??!");
});
console.log("文檔中心===========>檢測臨時文件目錄方法結(jié)束!");
}, function () {
console.log("文檔中心===========>創(chuàng)建文件夾失敗");
});
console.log("文檔中心===========>軟件準(zhǔn)備就緒:設(shè)置檢測文件存儲目錄結(jié)束");
};
以上就是web創(chuàng)建本地文件夾的實現(xiàn)方法,如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
JSP開發(fā)中hibernate框架的常用檢索方式總結(jié)
這篇文章主要介紹了JSP開發(fā)中hibernate框架的常用檢索方式總結(jié)的相關(guān)資料,需要的朋友可以參考下2017-04-04
JAVA/JSP學(xué)習(xí)系列之八(改寫MySQL翻頁例子)
JAVA/JSP學(xué)習(xí)系列之八(改寫MySQL翻頁例子)...2006-10-10
JSP開發(fā)之Spring方法注入之替換方法實現(xiàn)
這篇文章主要介紹了JSP開發(fā)之Spring方法注入之替換方法實現(xiàn)的相關(guān)資料,需要的朋友可以參考下2017-07-07

