[英]Angularjs blueimp fileUpload manually trigger submit
How can I manually trigger file uploads within an action of an angular controller? 如何在角度控制器的动作中手动触发文件上传?
This is my controller 这是我的控制器
angular.module('angular-app', ['blueimp.fileupload'])
.controller('NewsController', function($scope, $http) {
......
$scope.SaveNews = function() {
var url = baseUrl + '/Post',
data = $scope.News;
$http({
url: url,
method: 'POST',
data: data
}).success(function(data) {
$scope.News = data.Data;
---> something.submit(); // <--- THIS IS THE FILES SUBMIT
}
}).error(function(data) {
ShowAlert(data.Success);
});
};
I cannot trigger anything, any idea? 我无法触发任何事情,任何想法?
I had the same problem. 我有同样的问题。 My problem was getting the list of files.
我的问题是获取文件列表。 I solved this way
我这样解决了
//The list of files
$scope.$on('fileuploadchange', function (event, files) {
$scope.Files = files.files;
});
//The action triggered manually
$scope.SubmitAction = function(){
$('#fileUploadID').fileupload('send', {files: $scope.Files});
}
Pay attention to one thing, every time it is called "fileuploadchange" in the variable "files" you can find only the latest items added! 注意一件事,每次在变量“文件”中将其称为“ fileuploadchange”时,您只能找到添加的最新项!
检查文档: https : //github.com/blueimp/jQuery-File-Upload/wiki/API#wiki-programmatic-file-upload
$('#your-selector').fileupload('send', {files: your.data});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.