C# 使用ng文件上载上载多个文件
我正在尝试使用上载多个文件,但似乎无法使其正常工作 我的html是C# 使用ng文件上载上载多个文件,c#,angularjs,ng-file-upload,C#,Angularjs,Ng File Upload,我正在尝试使用上载多个文件,但似乎无法使其正常工作 我的html是 <input ngf-select ng-model="files" ngf-multiple="true" id="files" name="files" type="file" value="Choose File(s)" /> 我的问题可以归结为这样一个事实:UploadHandler(在服务器上)只被调用一次,并且只有一个文件进入。我的想法是,它应该为每个文件调用一次,因为它位于forEach循环中 if
<input ngf-select ng-model="files" ngf-multiple="true" id="files" name="files" type="file" value="Choose File(s)" />
我的问题可以归结为这样一个事实:UploadHandler(在服务器上)只被调用一次,并且只有一个文件进入。我的想法是,它应该为每个文件调用一次,因为它位于forEach循环中
if (context.Request.Files.Count > 0) //This is never greater than 1
{
HttpFileCollection SelectedFiles = context.Request.Files;
for (int i = 0; i < SelectedFiles.Count; i++) {
HttpPostedFile file = SelectedFiles[i];
}
}
if(context.Request.Files.Count>0)//该值从不大于1
{
HttpFileCollection SelectedFiles=context.Request.Files;
对于(int i=0;i
我已经检查了“网络”选项卡,每个文件都有自己的帖子。你是这么说的。。你收到上传的每个文件一个帖子吗?那么,3个选定文件的3个post?您正在一个接一个地发送文件,因此服务器上的每个请求也应该有1个文件。@danial您是对的(durr矩),但是uploadHandler方法只调用一次。无论我附加了多少个文件,都只调用一次,仅此而已。您是否在浏览器的“网络”选项卡中看到多个post请求被发送到服务器?
$scope.uploadFiles = function (files) {
if (files && files.length) {
angular.forEach(files, function (file) {
$log.warn("counter");
if (files && !file.$error) {
file.upload = Upload.upload({
url: "FileUpload.ashx",
file: file,
fields: {
FormInstanceGuid: $scope.model.FormInstanceGuid,
FormName: $scope.model.Template.Name
}
});
file.upload.then(function (response) {
$log.info("We have succeeded in our call!");
$log.info(response);
}, function (reason) {
$log.info("We have failed in our call!");
$log.info(reason);
});
}
});
if (context.Request.Files.Count > 0) //This is never greater than 1
{
HttpFileCollection SelectedFiles = context.Request.Files;
for (int i = 0; i < SelectedFiles.Count; i++) {
HttpPostedFile file = SelectedFiles[i];
}
}