cordova: download from url to android download folder
Fork,
you have to choose download file url,
local download file located here -
file:///storage/emulated/0/download
This link may help you -
Cordova - Download a file in download folder
Added file transfer plugin to download such as -
https://github.com/cfjedimaster/Cordova-Examples/tree/master/asyncdownload
choose any as per requirement
Comments
-
Roxx almost 2 years
Well before i start i tried below answers from stack overflow.
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/
But no luck at all.
I am trying to download a file from internet. My target is to download the file in download folder on Android phone.
I tried all the above answers and also i have used cordova example from cordova site.
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); } }; };
Any advise how to achieve this.