我想将数据从服务发送回我的控制器,如果文件范围的大小我怎么能在这里实现它是我的代码。
myApp.service('fileUpload', ['$http', function ($http) {
this.uploadFileToUrl = function (fileData, uploadUrl) {
if (fileData.size > 50000000) {
var fd = new FormData();
fd.append('file', fileData);
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: { 'Content-Type': undefined }
})
.success(function () {
})
.error(function () {
});
}
else {
return "Image size is more than 5MB";
}
}
}]);