I'm trying to upload the file but it keeps saying 'cannot read upload property of undefined' in this part of the controller:
$scope.upload = function (file) { Upload.upload....
The object Upload, being a parameter of the controller, is undefined.
My controller:
.controller('paramController',['$scope','Upload', function ($scope,$state,Upload, $location,$mdSidenav,mainService,loginService,resourceAccessService)
The function inside the controller:
$scope.upload = function (file) { Upload.upload({ url: 'upload/url', data: {file: file, 'username': $scope.username} }).then(function (resp) { console.log('Success ' + resp.config.data.file.name + 'cargado. Respuesta: ' + resp.data); }, function (resp) { console.log('Error: ' + resp.status); }, function (evt) { var progressPercentage = parseInt(100.0 * evt.loaded / evt.total); console.log('Progreso: ' + progressPercentage + '% ' + evt.config.data.file.name); }); };
Whenever I hit Upload, it says some field have to be filled, but I do not want it like that, just to upload the file.
And when filled, the javascript error above shows up.
Hi.
I'm trying to upload the file but it keeps saying 'cannot read upload property of undefined' in this part of the controller:
$scope.upload = function (file) { Upload.upload....
The object Upload, being a parameter of the controller, is undefined.My controller:
.controller('paramController',['$scope','Upload', function ($scope,$state,Upload, $location,$mdSidenav,mainService,loginService,resourceAccessService)
The function inside the controller:
$scope.upload = function (file) { Upload.upload({ url: 'upload/url', data: {file: file, 'username': $scope.username} }).then(function (resp) { console.log('Success ' + resp.config.data.file.name + 'cargado. Respuesta: ' + resp.data); }, function (resp) { console.log('Error: ' + resp.status); }, function (evt) { var progressPercentage = parseInt(100.0 * evt.loaded / evt.total); console.log('Progreso: ' + progressPercentage + '% ' + evt.config.data.file.name); }); };
And my html: `
Whenever I hit Upload, it says some field have to be filled, but I do not want it like that, just to upload the file. And when filled, the javascript error above shows up.
What am I doing wrong?