The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

472027 (2) [Avatar] Offline
#1
Hi All,
I am getting 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 :
$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 error doesn't appear, the problem is in the following line.
data: payload.

But commenting the above line doesn't upload the file.
jeremy.wilken (208) [Avatar] Offline
#2
Hello, you're talking about AngularJS, and that is a different forum for those questions.

https://forums.manning.com/forums/angularjs-in-action

I also don't have enough context to understand your code or problem. If this is not related to the book, you'll probably have better luck trying StackOverflow or other forums. Cheers.