2017-05-23 1 views
-1

イメージをアップロードするのに$ cordovaFileTransferを使用しますが、99%で停止します。PHPでは$ _FILESは空です。 と私はevtオブジェクトを取得します。

{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"16656","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"33040","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"98576","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"131344","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"147728","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"164112","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"180496","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"213264","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"229648","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"65808","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"82192","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"114960","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"295184","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"262416","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"311568","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"327952","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"344336","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"360720","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"377104","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"409872","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"442640","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"393488","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"426256","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"459024","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"475408","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"491163","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"196880","total":"491176"} 
{"bubbles":"false","cancelBubble":"false","cancelable":"false","lengthComputable":"true","loaded":"246032","total":"491176"} 

ロードされたプロパティには何が問題なのですか?


アップロードコード

$scope.upload = function(imageURI) { 
    $scope.dangerList[$scope.setting.num][$scope.setting.imageType + '1pic'] = imageURI; 
    var server = 'http://localhost/test.php'; 
    var dirName = 'check'; 
    var desName = 'test'; 
    var options = { 
     'httpMethod': 'POST', 
     'params': { 
      'dirName': dirName, 
      'desName': desName 
     } 
    }; 
    var promise = $cordovaFileTransfer.upload(server, imageURI, options, true); 
    promise.then(function(data) { 
     console.log(data); 
    }, function(data) {}, function(evt) { 
     $ionicLoading.show({ 
      template: '<p>upload:' + parseInt(100.0 * evt.loaded/evt.total) + '%</p>', 
      //duration: 1000, 
     }); 
    }); 
    return promise; 
}; 

とngCordova \ SRC \プラグイン\ fileTransfer.js

angular.module('ngCordova.plugins.fileTransfer', []) 

.factory('$cordovaFileTransfer', ['$q', '$timeout', function($q, $timeout) { 
    return { 
     download: function(source, filePath, options, trustAllHosts) { 
      var q = $q.defer(); 
      var ft = new FileTransfer(); 
      var uri = (options && options.encodeURI === false) ? source : encodeURI(source); 

      if (options && options.timeout !== undefined && options.timeout !== null) { 
       $timeout(function() { 
        ft.abort(); 
       }, options.timeout); 
       options.timeout = null; 
      } 

      ft.onprogress = function(progress) { 
       q.notify(progress); 
      }; 

      q.promise.abort = function() { 
       ft.abort(); 
      }; 

      ft.download(uri, filePath, q.resolve, q.reject, trustAllHosts, options); 
      return q.promise; 
     }, 

     upload: function(server, filePath, options, trustAllHosts) { 
      var q = $q.defer(); 
      var ft = new FileTransfer(); 
      var uri = (options && options.encodeURI === false) ? server : encodeURI(server); 

      if (options && options.timeout !== undefined && options.timeout !== null) { 
       $timeout(function() { 
        ft.abort(); 
       }, options.timeout); 
       options.timeout = null; 
      } 

      ft.onprogress = function(progress) { 
       q.notify(progress); 
      }; 

      q.promise.abort = function() { 
       ft.abort(); 
      }; 

      ft.upload(filePath, uri, q.resolve, q.reject, options, trustAllHosts); 
      return q.promise; 
     } 
    }; 
}]); 

0123インターセプターを押します

数日前に動作する可能性があります。 時間の間、

  1. 代わり[email protected][email protected]とplaformを追加します。
  2. update cordova;
  3. ionic 1.7.3を使用してください。ここ

とは、それが作品をすることができますが、これは実際にcordovaFileTransferのprogressイベントからの応答で二回

$scope.down = function(fname) { 
    var fileTransfer = new FileTransfer(); 
    var uri = encodeURI($rootScope.rootUrl + fname); 
    var fileURL = cordova.file.externalRootDirectory + fname; 
    fileTransfer.download(
     uri, 
     fileURL, 
     function(entry) { 
      console.log(entry); 
     }, 
     function(error) { 
      console.log(error); 
     }, 
     false, { 
      headers: { 
       "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA==" 
      } 
     } 
    ); 
}; 
+0

こんにちは。あなたの質問を明確にしてください、私はそれの現在の状態が残念なことに答えにつながることはない残念ながら... – DotBert

答えて

0

ファイルをダウンロードし、ダウンロードコードです。それは、このような応答に何かをあげる成功した :

Object {bytesSent: 3228135, responseCode: 200, response: "<!-- Served from 80.251.0.59/test.talia.net, as …imited↵</p>↵↵</td></tr></table>↵↵</body>↵</html>↵", objectId: ""} 

しかし、あなたが取得している出力ごとに、私はあなたの全体のファイルがほとんどでアップロードされたため、関数が別のインスタンスから同じ方法によって中断なっていると思い

最後の3行目。

"cancelable":"false","lengthComputable":"true","loaded":"491163","total":"491176"} 

それから、別のポイントから取得しました。 コードを提供してください。私はさらにあなたを支援しようとすることができます。 ありがとうございました

+0

私はちょうど@PRANSHU MIDHAのいくつかのコードを追加し、助けをありがとう – teemo

+0

**決議**:\t ダウングレード1.6.3から1.5.0へのcodeova-plugin-file-pluginを実行してから動作します。 – teemo

+0

クールな男!コーディングを続ける! –

関連する問題