我有一个html
form
将该文件提交到angular js
:
<form id="uploadForm">
<div id="republishBulk" class="panel-collapse collapse desc vertical" style="display: none; text-align: left">
<div class="horizontal">
<div class="dropdown">
<button type="button" class="btn btn-light dropdown-toggle" data-toggle="dropdown" id="selectSource1" aria-haspopup="true" aria-expanded="true">
Source system
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu1">
<h5 class="dropdown-header">Source system</h5>
<a class="dropdown-item" href="#" data-value="s1">S1</a>
<a class="dropdown-item" href="#" data-value="s2">S2</a>
<a class="dropdown-item" href="#" data-value="s3">S3</a>
</div>
</div>
<div class="col-md-7">
<input id="upload" type="file" class="form-control" placeholder="Upload republish file" file-model="uploadedRepublishFile" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"/>
</div>
<div class="form-group mb-3">
<div class="form-group" aria-label="file upload">
<input id="republish" type="submit" class="btn btn-primary"
ng-click="doRepublishFile()" value="Upload"/>
</div>
</div>
</div>
</div>
</form>
我的控制器将文件传递到我的spring controller
的位置:
$scope.doRepublishFile = function() {
var file = $scope.uploadedRepublishFile;
var url = "/republishfile";
var data = new FormData();
data.append('republishfile', file);
var config = {
transformRequest: angular.identity,
headers: {
'Content-Type': undefined
}
}
$http.post(url, data, config).then(
function(response) {
$rootScope.republishData = response.data;
});
};
我可以计算angular js
中文件的行数吗?
我需要显示一个alert box
,该文件包含一个指定的行数,并带有一个OK
和Cancel
按钮。仅在选择OK
时才应调用弹簧控制器。
任何帮助将不胜感激。