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("文檔中心===========>軟件準備就緒:設(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("文檔中心===========>軟件準備就緒:設(shè)置檢測文件存儲目錄結(jié)束"); };
以上就是web創(chuàng)建本地文件夾的實現(xiàn)方法,如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
標簽:南京 貸款邀約 黃石 大連 內(nèi)江 銅川 樂山 廣州
巨人網(wǎng)絡(luò)通訊聲明:本文標題《web 開發(fā)之創(chuàng)建本地文件夾的實現(xiàn)方法》,本文關(guān)鍵詞 web,開,發(fā)之,創(chuàng)建,本地,文件夾,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。