2013-04-16 41 views

回答

0

爲此,您可以使用電話的差距文件API文件傳送對象

如果你想下載多個文件,那麼你可以使用文件傳輸的循環或者下載文件是zip格式,然後它會很容易爲你的文件轉移和extract zip plugin

方法1>

樣品文件傳輸代碼:

配置郵編插件然後使用這個代碼

function download(remoteFile) 
{ 
     var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/') + 1); 
      window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) { 
       fileSystem.root.getFile(localFileName, { create: true, exclusive: false }, function (fileEntry) { 
        var localPath = fileEntry.fullPath; 
        console.log("localPath1:" + localPath); 
        if (device.platform === "Android" && localPath.indexOf("file://") === 0) { 
         localPath = localPath.substring(7); 
        } 
        console.log("localPath2 save:" + localPath); 
       console.log("thid is localFileName :"+localFileName); 
        extractFile(localFileName); //No need for other formated file except zip file. 
        var ft = new FileTransfer(); 
        ft.download(remoteFile, 
         localPath, function (entry) { 
          console.log("file path:" + entry.fullPath); 
          var linkopen = document.getElementById("openlink"); 
          linkopen.style.display = "block"; 
          linkopen.href = entry.fullPath; 
          var zippath = entry.fullPath; 
          console.log(zippath); 
          $("#btnExtract").show(); 

         }, fail); 
       }, fail); 
      }, fail); 
     console.log("completed"); 
} 

*這裏寫這個代碼考慮壓縮文件中。你需要改變代碼。

方法2:刪除

extractFile(localFileName);

代碼