Amacım, "/ sdcard/files/excel /" veya "/ sdcard/files/pdf /" gibi bir klasör oluşturmaktır. sdcard
'dan sonraki kısım bir url'den gelir ("/ files/excel"). Bu yüzden önce "/ files/excel" olup olmadığını kontrol etmek istiyorum, eğer mevcut değilse bir dosya oluşturun. Ad, "localFileName" adlı url'den geliyor.Phonegap: Belirli bir klasördeki dosya oluşturun
Bu durumda folder = "files/excel" ve localFileName = "Sheet1.html".
fs.root.getDirectory satırından sonra FileError.PATH_EXISTS_ERR adı verilen Hata 12'yi aldım ancak sdcard'da klasör veya dosya yok.
https://github.com/torrmal/cordova-simplefilemanagement
Sen damgası oluşturabilirsiniz dizinleri:
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);
@ Bu [link] de dhaval (http://stackoverflow.com/questions/10961000/nested-directory-creator-phonegap) bu yüzden benim kodum 'window.requestFileSystem (LocalFileSystem.PERSISTENT, 0,)işlevi (dosyaSistemi) { window.FS = fileSystem; var printDirPath = işlev (giriş) { console.log ("Yönlendirme yolu -" + entry.fullPath);} createDirectory (klasör, localFileName, remoteFile, printDirPath); }, başarısız); @dhaval 'in create directory yöntemini kullandım – engincancan