D
D
dellakeram2018-06-13 14:10:45
JavaScript
dellakeram, 2018-06-13 14:10:45

How to implement file download to phone in Apache Cordova?

Hello,
How can I download a picture or file (pdf, excel) to my phone?
Explain on your fingers please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Maltsev, 2018-07-24
@mrhard

https://cordova.apache.org/docs/en/6.x/reference/c...

var fileTransfer = new FileTransfer();
var uri = encodeURI("http://some.server.com/download.php");

fileTransfer.download(
    uri,
    fileURL,
    function(entry) {
        console.log("download complete: " + entry.toURL()); //Далее делаем со скаченным файлом что хотим 
    },
    function(error) {
        console.log("download error source " + error.source);
        console.log("download error target " + error.target);
        console.log("download error code" + error.code);
    },
    false,
    {
        headers: {
            "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
        }
    }
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question