How to make POST requests with the FormData API

You can add something like this:

 myapp.controller("myController",function($scope,$http){
        $scope.signup = function(){    
        var form_data = new FormData();
        angular.forEach($scope.files,function(file){
                form_data.append('file',file);
        });
        form_data.append('susername',$scope.susername);  // new line
        var config = {headers: { 'Content-type': undefined } };
        $http.post("picupload.php",form_data, config)
                .success(function(response){
                alert(response);
        });                
}   

I’m not sure about PHP but after googling I found that in php ‘susername’ can retrieved as below:

$_POST['susername'];

Leave a Comment