0
我上传了一些元素到S3。我使用的是相同的例子此链接里面:从文件上传文章中获取网址
myApp.controller('myCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){
$scope.uploadFile = function(){
var file = $scope.myFile;
console.log('file is ');
console.dir(file);
var uploadUrl = "/fileUpload";
fileUpload.uploadFileToUrl(file, uploadUrl);
};
在这一点上,它的工作原理,但现在,我需要追赶上载的文件的URL。我怎样才能做到这一点?我是新的上传文件:/
myApp.service('fileUpload', ['$http', function ($http) {
this.uploadFileToUrl = function(file, uploadUrl){
var fd = new FormData();
fd.append('file', file);
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
})
.success(function(){
})
.error(function(){
});
}
}]);
Thanx提前。
的'.success'和'.error'方法弃用。有关更多信息,请参阅[为什么不推荐使用角度$ http成功/错误方法?从V1.6删除?](https://stackoverflow.com/questions/35329384/why-are-angular-http-success-error-methods-deprecated-removed-from-v1-6/35331339#35331339)。 – georgeawg