0

I am fairly new to PhoneGap and I am using the below snippet of code to download a file into the app, so that it can be used later in other screens. But my app is not showing any alert message and I am not sure how do I debug this.

Note: I have installed file and file-transfer plugins for phonegap.

Code Snippet: (Copied from another thread and trying to learn from it)

<body>
    Testing file transfer 3.
    <script type="text/javascript" src="cordova.js"></script> 
    <script type="text/javascript" src="js/index.js"></script> 
    <script type="text/javascript" src="js/jQuery_v3_3_1.js"></script>
    <script type="text/javascript">
        app.initialize();

        function storeIntelligrapeLogo(){
          var url = "https://extranet.bwfbadminton.com/docs/players/50906/profile/50906.jpg"; // image url

            document.addEventListener("deviceready", function() { 
              window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
                  var imagePath = fs.root.fullPath + "/logo.png"; // full file path
                  var fileTransfer = new FileTransfer();
                  fileTransfer.download(url, imagePath, function (entry) {
                           alert(entry.fullPath); // entry is fileEntry object
                  }, function (error) {
                        alert("Error");
                           alert(error);
                  });
               });
            }, false);
        }

        storeIntelligrapeLogo();

    </script>
</body>
Abhilash M
  • 39
  • 8
  • I am going through this documentation -https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html but still my code is not working near the line window.requestFileSystem. – Abhilash M Jan 19 '19 at 23:17
  • Check this answer: https://stackoverflow.com/questions/43575581/cordova-download-a-file-in-download-folder – proofzy Jan 21 '19 at 12:24

0 Answers0