<input type="submit"class="btn btn-primary" ng-click="uploadFile()" value="确定">
$scope.uploadFile = function (e) {
$("#myModalChoose").modal(‘hide‘);
var file = document.getElementById(‘chooseFile‘).files[0];
if (file.size == 0) {
alert(‘请选择文件‘);
return;
}
var fd = new FormData();
var fileName = $("#chooseFile").val();
fd.append("file", document.getElementById(‘chooseFile‘).files[0]);
fd.append("fileInfo.name", fileName);
fd.append("fileInfo.remark", $scope.chooseRemark);
fd.append("fileInfo.version", $scope.chooseVersion);
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.open("POST", root + "/ly/fileInfo/save.action");
xhr.send(fd);
}
function uploadComplete(evt) {
alert("文件上传完毕!");
$scope.page();
}
function uploadFailed(evt) {
alert(‘系统异常,上传失败!‘);
}
function uploadCanceled(evt) {
alert(‘链接异常,上传失败!‘);
}