Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用wcf服务上传angularjs中的文件?_Angularjs_Wcf - Fatal编程技术网

如何使用wcf服务上传angularjs中的文件?

如何使用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 = $

我卡在我的应用程序,我想上传文件使用角js与wcf服务,我使用wcf服务操纵到数据库。 我已经为文件上传创建了一个指令

    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为单位)