내 목표는 "/ sdcard/files/excel /"또는 "/ sdcard/files/pdf /"와 같은 폴더를 만드는 것입니다. sdcard
이후의 부분은 url ("/ files/excel")에서 가져옵니다. 먼저 "/ files/excel"이 있는지 확인한 다음 존재하지 않으면 파일을 만듭니다. 이름은 "localFileName"이라는 URL에서옵니다.Phonegap : 특정 폴더에 파일 만들기
이 경우 folder = "files/excel"및 localFileName = "Sheet1.html"입니다.
fs.root.getDirectory 줄 뒤에 FileError.PATH_EXISTS_ERR이라는 오류 12가 발생했습니다. 하지만 폴더 나 파일이 sdcard에 없습니다.
https://github.com/torrmal/cordova-simplefilemanagement
당신은 재귀 적으로 만들 수 있습니다 디렉토리 :
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
var folder = file_path.substring(0,file_path.lastIndexOf('/'));
console.log(folder);
fs.root.getDirectory(folder,{create: true, exclusive: false},function (datadir) {
console.log(folder);
datadir.getFile(localFileName, {create: true, exclusive: false},function(fileEntry) {
var ft = new FileTransfer();
yol = "/sdcard/"+folder+localFileName;
ft.download(remoteFile,yol,function(entry) {
console.log(entry.fullPath);
}, fail);
}, fail);
}, fail);
}, fail);
는 @ dhaval이 [링크] (http://stackoverflow.com/questions/10961000/nested-directory-creator-phonegap) 여기 내 코드'window.requestFileSystem (LocalFileSystem.PERSISTENT, 0, function (fileSystem) { window.FS = fileSystem; var printDirPath = function (entry) { console.log ("Dir path -"+ entry.fullPath);} createDirectory (folder, localFileName, remoteFile, printDirPath); }, 실패);'@dhaval의 디렉토리 생성 메소드를 사용했습니다. – engincancan