複数のファイルのアップロードはangularjsでうまく動作しますが、私の.then()関数内でファイル名を取得できません。 ! AngularJs複数のファイルをアップロードする.then
この
は私のアップロードファイル機能である: それがうまく機能$scope.uploadFile = function(files,destinationPhp) {
$scope.montrerLoader = true;
for (var x=0;x<files.length;x++){
var fd = new FormData();
//Take the first selected file
fd.append("file", files[x]);
console.log(files[x].name);
var uploadUrl = destinationPhp;
$http.post(uploadUrl, fd, {
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
}).then(function(data){
$scope.montrerLoader = false;
if(data.data.reponse=='ok'){
if(destinationPhp=='uploadFichier.php'){
Notification.success('Fichier transféré!');
$scope.rendezVous.fichiers.push({'nom':files[x].name});
}
}
else{
Notification.error(data.data.reponse);
}
});
}
};
、ファイルは私のサーバーのディレクトリにアップロードしますが、問題は私が必要とするこの行を次のとおりです。
$scope.rendezVous.fichiers.push({'nom':files[x].name});
I
TypeError: files[x] is undefined
私はファイル名をTEMPに入れようとしたように、たくさん試しました。 var、それは決して認識されない、または結局は常に同じ名前ファイルをプッシュします(これはロジックではありません)。
$ scope.rendezVousにアップロードした後にファイル名をプッシュする方法はありますか?
console.log(files[x].name);
私の放火魔コンソール内部の権利のファイル名を表示!!:
illerは、この行があることですしかし、私が内部で使用しようとする限り、()その後、それは動作しません!