0 Replies Latest reply on Apr 27, 2017 11:28 PM by sethup51656429

    File download error code 1

    sethup51656429 Level 1

      this is my html

       

      <!DOCTYPE html>

      <html>

        <head>

        <title></title>

       

       

      <script type="text/javascript"  src="cordova.js"></script>

          <script type="text/javascript">

       

       

       

       

       

       

      function onBodyLoad()

      {

      document.addEventListener("deviceready", onDeviceReady, false);

      }

       

          function downloadFile(){

        alert("in");

       

              window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,

          function onFileSystemSuccess(fileSystem) {

              fileSystem.root.getFile(

              "dummy.html", {create: true, exclusive: false},

              function gotFileEntry(fileEntry) {

                  var sPath = fileEntry.fullPath.replace("dummy.html","");

                  var fileTransfer = new FileTransfer();

                  fileEntry.remove();

       

       

                  fileTransfer.download(

                      "http://www.w3.org/2011/web-apps-ws/papers/Nitobi.pdf",

                      sPath + "theFile.pdf",

                      function(theFile) {

                          alert("download complete: " + theFile.toURI());

                          showLink(theFile.toURI());

                      },

                      function(error) {

                         //alert("download error source " + error.source);

                        //  alert("download error target " + error.target);

                         alert("upload error code: " + error.code);

                      }

                  );

              }, fail);

          }, fail);

       

       

       

          }

       

          function showLink(url){

              alert(url);

              var divEl = document.getElementById("ready");

              var aElem = document.createElement("a");

              aElem.setAttribute("target", "_blank");

              aElem.setAttribute("href", url);

              aElem.appendChild(document.createTextNode("Ready! Click To Open."))

              divEl.appendChild(aElem);

       

          }

       

       

          function fail(evt) {

             alert(evt.target.error.code+" error");

          }

       

       

       

      function onDeviceReady()

      {

       

       

              downloadFile();

      }

       

          </script>

        </head>

        <body onload="onBodyLoad()">

      <h1>Hey, it's PhoneGap!</h1>

      <p>Don't know how to get started? Check out <em><a target="_blank" href="/http://www.phonegap.com/start">PhoneGap Start</a><em>

      </p>

      <br />

          <p>

              DOWNLOADING FILE...<br />

              <span id="ready"><img src='http://antcolony.in/shammer1/site//uploads/unnamed.png'></span>

          </p>

        </body>

      </html>

       

      i just want to download image from server ..

       

      my config.xml

      <?xml version='1.0' encoding='utf-8'?>

      <widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">

          <name>File Downloader</name>

          <description>

              sethu p sanil

        first build at 28-04-2017

        only file download code added

        all information @ README.md

          </description>

          <author email="support@phonegap.com" href="http://phonegap.com">

              PhoneGap Team

          </author>

          <content src="index.html" />

          <preference name="DisallowOverscroll" value="true" />

          <preference name="android-minSdkVersion" value="14" />

        

          <plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />

         

          <plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />

          <platform name="android">

              <icon density="ldpi" src="www/res/icon/android/drawable-ldpi-icon.png" />

              <icon density="mdpi" src="www/res/icon/android/drawable-mdpi-icon.png" />

              <icon density="hdpi" src="www/res/icon/android/drawable-hdpi-icon.png" />

              <icon density="xhdpi" src="www/res/icon/android/drawable-xhdpi-icon.png" />

              <icon density="xxhdpi" src="www/res/icon/android/drawable-xxhdpi-icon.png" />

              <icon density="xxxhdpi" src="www/res/icon/android/drawable-xxxhdpi-icon.png" />

              <splash density="land-ldpi" src="www/res/screen/android/drawable-land-ldpi-screen.png" />

              <splash density="land-mdpi" src="www/res/screen/android/drawable-land-mdpi-screen.png" />

              <splash density="land-hdpi" src="www/res/screen/android/drawable-land-hdpi-screen.png" />

              <splash density="land-xhdpi" src="www/res/screen/android/drawable-land-xhdpi-screen.png" />

              <splash density="land-xxhdpi" src="www/res/screen/android/drawable-land-xxhdpi-screen.png" />

              <splash density="land-xxxhdpi" src="www/res/screen/android/drawable-land-xxxhdpi-screen.png" />

              <splash density="port-ldpi" src="www/res/screen/android/drawable-port-ldpi-screen.png" />

              <splash density="port-mdpi" src="www/res/screen/android/drawable-port-mdpi-screen.png" />

              <splash density="port-hdpi" src="www/res/screen/android/drawable-port-hdpi-screen.png" />

              <splash density="port-xhdpi" src="www/res/screen/android/drawable-port-xhdpi-screen.png" />

              <splash density="port-xxhdpi" src="www/res/screen/android/drawable-port-xxhdpi-screen.png" />

              <splash density="port-xxxhdpi" src="www/res/screen/android/drawable-port-xxxhdpi-screen.png" />

          </platform>

          <feature name="http://api.phonegap.com/1.0/file" />

      <feature name="File">

             <param name="android-package" value="org.apache.cordova.file.FileUtils" />

      </feature>

      <feature name="FileTransfer">

            <param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer" />

      </feature>

      <feature name="Storage">

             <param value="org.apache.cordova.Storage" name="android-package"/>

      </feature>

         

          <access origin="*" />

          <allow-intent href="http://*/*" />

          <allow-intent href="https://*/*" />

          <allow-intent href="tel:*" />

          <allow-intent href="sms:*" />

          <allow-intent href="mailto:*" />

          <allow-intent href="geo:*" />

          <platform name="android">

              <allow-intent href="market:*" />

          </platform>

          <platform name="ios">

              <allow-intent href="itms:*" />

              <allow-intent href="itms-apps:*" />

          </platform>

          <plugin name="cordova-plugin-file-transfer" spec="~1.5.1" />

      </widget>

       

      can you help me?