我正在开发angularjs应用程序,我可以动态地上传多个文件。让我解释一下这个场景。我将在API中获得所需的文档列表。我将绑定如下。
<div class="upload-button" ng-repeat="file in files">
<div class="upload-button-icon">
<img src="images/folder-small.png">
<div class="upload-text">{{file}}</div>
<input type="file" id="file1" name="file1" />
</div>
</div>
<div class="button-container margin-top80">
<input type="submit" value="{{ 'Save' | translate }}" ng-click="uploadFiles()" class="blue-button">
</div>
我试过如下。
$scope.upload = function () {debugger;
alert($scope.files.length + " files selected ... Write your Upload Code");
var fileuploadurl = baseurl + 'api/Customer/UploadLeaseFiles/' + LoginID + '/' + "GOSI";
for (var i = 0; i < $scope.files.length; i++) {
var $file = $scope.files[i];
$upload.upload({
url: fileuploadurl,
file: $file,
progress: function (e) {
// wait...
}
})
.then(function (data, status, headers, config) {
alert('file is uploaded successfully');
});
}
alert('file is uploaded successfully');
};
此代码给出了错误eferenceError:$ upload未定义。
我想将这些文件提交给API。我可以知道我该怎么办?任何帮助将不胜感激。谢谢。