Phonegap Filetransfer Download
I'm new on stackoverflow. it's the first time that I have to use Phonegap and really I have a problem. I need to make a table and by clicking on each element starts to download a p
Solution 1:
First of all your url is invalid included http multiple times
var url = 'http://http://legalespymes.com.ar/legalespymes/abonos/aseguradoras.pdf';
change like this
var url = 'http://legalespymes.com.ar/legalespymes/abonos/aseguradoras.pdf';
If you are create multiple directory and store file inside that directory this may be create issue.(example [project/sample/local] not created same time. so file not download).And make sure file download plugins are available in config.xml and specify phonegap version.
Use this code to create multiple directory at time.
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
// create directoryfunctiongotFS(fileSystem) {
window.FS = fileSystem;
var printDirPath = function(entry){
console.log("Dir path - " + entry.fullPath);
}
createDirectory("local/path/to/your", printDirPath);
}
functionfail() {
console.log("failed to get filesystem");
}
functioncreateDirectory(path, success){
var dirs = path.split("/").reverse();
var root = window.FS.root;
var createDir = function(dir){
console.log("create dir " + dir);
root.getDirectory(dir, {
create : true,
exclusive : false
}, successCB, failCB);
};
var successCB = function(entry){
root = entry;
if(dirs.length > 0){
createDir(dirs.pop());
}else{
success(entry);
}
};
var failCB = function(){
};
createDir(dirs.pop());
}
Now you write your file download code .
Post a Comment for "Phonegap Filetransfer Download"