document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
//request the persistent file system
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, fileSystemSuccess, fileSystemFail);
}
function fileSystemSuccess(fileSystem) {
var directoryEntry = fileSystem.root; // to get root path to directory
directoryEntry.getDirectory("teste_recev", {create: true, exclusive: false}, onDirectorySuccess, onDirectoryFail);
var rootdir = fileSystem.root;
var fp = rootdir.fullPath;
fp = fp+"/teste_recev/image_name.jpg";
var fileTransfer = new FileTransfer();
fileTransfer.download("https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/t1.0-1/c14.4.48.48/150734_264955536974736_682293823_t.jpg",fp,
function(entry) {
alert("download complete: " + entry.fullPath);
},
function(error) {
alert("download error source " + error.source);
alert("download error target " + error.target);
alert("upload error code" + error.code);
}
);
}
function onDirectorySuccess(parent) {
console.log(parent);
}
function onDirectoryFail(error) {
alert("Unable to create new directory: " + error.code);
}
function fileSystemFail(evt) {
console.log(evt.target.error.code);
}
But have a error:
- dowload error source https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/t1.0-1/c14.4.48.48/150734_264955536974736_682293823_t.jpg
- download error target//teste_recev/image_name.jpg
- upload error code1
i have, the cordova.js in project, have link for cordova.js but have this erros if someone to help, really appreciate it.
Try like this