2016-12-13 5 views
0

Gut bevor ich anfange, versuchte ich unter Antworten von Stapelüberlauf.cordova: download von url nach android herunterladen ordner

Download file to downloads folder ios/android using phonegap

FileTransfer Cordova download path

Download a file to Downloads folder of device using Cordova FileTransfer

http://www.phonegaptutorial.com/downloading-an-image-from-the-internet-with-phonegap/

Aber kein Glück überhaupt.

Ich versuche, eine Datei aus dem Internet herunterzuladen. Mein Ziel ist es, die Datei im Download-Ordner auf Android-Handy herunterzuladen.

Ich versuchte alle oben genannten Antworten und auch ich habe Cordova Beispiel von Cordova Website verwendet.

https://cordova.apache.org/docs/en/2.0.0/cordova/file/filetransfer/filetransfer.html

function downloadCL(){ 

var url = "http://www.phonegaptutorial.com/wp-content/uploads/examples/phonegap-logo.png"; 

// we need to access LocalFileSystem 
window.requestFileSystem(window.LocalFileSystem.PERSISTENT, 0, function(fs) 
{ 
    // create the download directory is doesn't exist 
    fs.root.getDirectory('downloads', { create: true }); 

    // we will save file in .. downloads/phonegap-logo.png 
    var filePath = fs.root.fullPath + '/downloads/' + url.split('/').pop(); 
    var fileTransfer = new window.FileTransfer(); 
    var uri = encodeURI(decodeURIComponent(url)); 

    fileTransfer.download(uri, filePath, function(entry) 
    { 
     alert("Successfully downloaded file, full path is " + entry.fullPath); 
    }, 
    function(error) 
    { 
     console.log("Some error " + error.code + " for " + url +); 
    }, 
    false); 
} 
          }; 
}; 

Jede beraten, wie dies zu erreichen.

+0

warum unten abstimmen? was ist daran falsch?. Zumindest den Grund kommentieren. – Ironic

Antwort

Verwandte Themen