If someone is facing the same problem, here is the answer:
To download a file, you should not just add the path to the folder where it will be downloaded, you should also add the path to the file itself.
So, if you upload a jpg-image in the "Documents", the path to the file should be: "Document" + ". Jpg".
here is the code after modification:
function DownloadFile(){ var fileTransfer = new FileTransfer(); var url ="http://www.ranafrog.org.au/f006.jpg"; var folderpath=persistent_root.fullPath+"frog.jpg"; //The path is added here. var onSuccess= function(entry){ console.log("download complete: " + entry.fullPath); }; var onError=function(error) { console.log("download error source " + error.source); console.log("download error target " + error.target); console.log("upload error code " + error.code); }; fileTransfer.download(url,folderpath,onSuccess,onError); }
I'm not sure what I'm saying is 100% correct or not, but what worked for me, so hope this helps =)
source share