472027 (2) [Avatar] Offline
#1
Hi All,
I am getting the following error while developing program for upload file in AngularJS

$rootScope.get_request_param.indexOf is not a function

Please reply as soon as possible.

Thanks in advance.
Harish Pathak

The code is as :

app.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]);
            });
         });
      }
   };
}]);


$scope.uploadFile = function() {
 

$rootScope.$broadcast('authorize-session­');
 

if($scope.myFile==undefined) {

toaster.pop('fail', '', 'Please select a file');

}


var payload = new FormData();

payload.append("file", $scope.myFile);

payload.append("taskPerform", "upload_file");

payload.append("issueid", issueid);
 

$http({

headers: { 'Content-Type': undefined},

url: './assets/tools/classes/view_issue_info_­class.php',

method: "POST",

data: payload,

transformRequest: angular.identity

})


.success(function(result) {
 

if(result==1) {

toaster.pop('success', 'Success', 'File uploaded successfully');

setTimeout(redirectPage,4000);

}

});

}




If I comment following line in the code, error doesn't appear.
data: payload.

Please tell, what could be the problem. ?

Please help. Its urgent.

Thanks