0
我卡在我的應用程序中,我想用wcf服務使用角度js上傳文件,我使用wcf服務來操縱數據庫。 我已經創建了一個文件上傳指令。如何使用wcf服務在angularjs中上傳文件?
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]);
});
});
}
};
}]);
和服務調用Post方法。
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服務時說這個大小太大了。 所以任何人都可以幫助我,我怎樣才能將文件片段分塊並上傳。