如何使用wcf服务上传angularjs中的文件?
我卡在我的应用程序,我想上传文件使用角js与wcf服务,我使用wcf服务操纵到数据库。 我已经为文件上传创建了一个指令如何使用wcf服务上传angularjs中的文件?,angularjs,wcf,Angularjs,Wcf,我卡在我的应用程序,我想上传文件使用角js与wcf服务,我使用wcf服务操纵到数据库。 我已经为文件上传创建了一个指令 myApp.directive('fileModel', ['$parse', function ($parse) { return { restrict: 'A', link: function (scope, element, attrs) { var model = $
myApp.directive('fileModel', ['$parse', function ($parse) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var model = $parse(attrs.fileModel);
var modelSetter = model.assign;
element.bind('change', function () {
scope.$apply(function () {
modelSetter(scope, element[0].files[0]);
});
});
}
};
}]);
和服务呼叫后方法
myApp.service('fileUpload', ['$http', function ($http) {
this.uploadFileToUrl = function (file, uploadUrl) {
var fd = new FormData();
fd.append('file', file);
debugger;
$http.post('http://localhost:50202/WcfService/Service1.svc/fileUpload', fd, {
transformRequest: angular.identity,
headers: { 'Content-Type': undefined }
})
.success(function () {
})
.error(function () {
});
}
}]);
所以问题是,当文件转换为字节wcf服务时,表示大小太大。
所以,有谁能帮我,我怎样才能把文件分割成块并上传呢 您需要增加Web.config中的最大消息长度:
<configuration>
<system.web>
<httpRuntime maxMessageLength="409600"
executionTimeoutInSeconds="300"/>
</system.web>
</configuration>
这将最大消息长度设置为400 MB(参数以kB为单位)