0

I am using this approach to try to download a file. But at the 'getFile' call, all I am getting is the error code 9, what should be a permission error.

I am using build.phonegap.com to build my app. In the config file I added the plugins and permissions.

    <gap:plugin name="org.apache.cordova.file" />
    <gap:plugin name="org.apache.cordova.file-transfer" />
    <feature name="http://api.phonegap.com/1.0/file"/>

The phonegap version is 3.1.0. What I am doing wrong?

Community
  • 1
  • 1
Chris
  • 1,610
  • 3
  • 18
  • 37
  • refer my ans this wil help you - http://stackoverflow.com/questions/21577230/phonegap-save-image-from-url-into-device-photo-gallery/21579097#21579097 – Suhas Gosavi Feb 21 '14 at 12:24

1 Answers1

0

I believe your not suppose to use getFile but the call (readAsText)

Example code below:

function win(file) {
var reader = new FileReader();
reader.onloadend = function (evt) {
    console.log("read success");
    console.log(evt.target.result);
};
reader.readAsText(file);
 };

 var fail = function (error) {
console.log(error.code);
  };

entry.file(win, fail);

See Phonegap API docs for more info: http://docs.phonegap.com/en/edge/cordova_file_file.md.html#FileReader

Alan
  • 157
  • 1
  • 2
  • 9